标签:java re c ar 时间 new amp mil
项目需要把 long 转换成 Timestamp,而且需要是 UTC 时间格式。
网上 google了好久,总结了这个写法
Calendar cal = Calendar.getInstance(); long value = cal.getTimeInMillis(); //your long value. int zoneOffset = cal.get(Calendar.ZONE_OFFSET); int dstOffset = cal.get(Calendar.DST_OFFSET); cal.setTimeInMillis(value); cal.add(Calendar.MILLISECOND, -(zoneOffset+dstOffset)); //it only takes int int System.out.println(new Timestamp(cal.getTimeInMillis()));
标签:java re c ar 时间 new amp mil
原文地址:http://my.oschina.net/u/1767744/blog/294709