日期转化

将格林尼治时间转化为标准时间

SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String dateStr = dateformat.format(System.currentTimeMillis());

将标准时间转化为格林尼治时间

SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
    long time = dateformat.parse("2016-09-02 23:02:17").getTime();
    System.out.println(time);
} catch (ParseException e) {
    e.printStackTrace();
}
由此可以看到日期的转化是相互的

猜你喜欢

转载自www.cnblogs.com/xuanyuer/p/10231681.html