如题,我该如何把这个131460562376400000转换为java的yyyy-mm-dd HH:mm:ss.SSS呢,试过了以下方法都不得行!
/**
* 将C#的ticks值转换成Java的yyyy-mm-dd HH:mm:ss.SSS
*
* @param ticks
* @return
*/
public static String fromDnetTicks2JdateString(long ticks) {
TimeZone timeZone = TimeZone.getDefault();
long TICKS_PER_MILLISECOND = 10000;
long TICKS_AT_EPOCH = 621355968000000000L;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Calendar calendar = Calendar.getInstance(timeZone);
calendar.setTimeInMillis((ticks - TICKS_AT_EPOCH) / TICKS_PER_MILLISECOND);
calendar.setTimeInMillis(calendar.getTimeInMillis() - calendar.getTimeZone().getRawOffset());
return sdf.format(calendar.getTime());
}
相关分类