如何将时间戳转换为自 Unix 纪元以来的秒数?我只是将时间戳转换为UTC时间戳。现在我想将此时间戳转换为秒。
Calendar currenttime = Calendar.getInstance();
System.out.println("current: "+currenttime.getTime());
//TIMESTAMP UTC/GMT
TimeZone z = currenttime.getTimeZone();
int offset = z.getRawOffset();
if(z.inDaylightTime(new Date())){
offset = offset + z.getDSTSavings();
}
int offsetHrs = offset / 1000 / 60 / 60;
int offsetMins = offset / 1000 / 60 % 60;
currenttime.add(Calendar.HOUR_OF_DAY, (-offsetHrs));
currenttime.add(Calendar.MINUTE, (-offsetMins));
System.out.println("GMT CURRENT TIME: "+currenttime);