题解 | #日期换算#

日期换算

http://www.nowcoder.com/practice/08f8a66cb5584268a78ecca2749a2da5

    //write your code here......
    String[] arr = str1.split(" ");

    if (arr.length != 6){
        System.out.println("您输入的数据不合理");
    }else{
        String str = arr[0]+"-"+arr[1]+"-"+arr[2]+" "+arr[3]+":"+arr[4]+":"+arr[5];

        Date date = sdf.parse(str);

        System.out.println("北京时间为:" + sdf.format(date));
        System.out.println("纽约时间为:" + sdf.format(date.getTime()-(long)12*60*60*1000));

    }
}

}

全部评论

相关推荐

投递美团等公司9个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务