The JDK1.8 API saies the result of the Date(long date) is based on the time January 1, 1970, 00:00:00 GMT, but when I test it by set the date=0, I find the result is not the Thu Jan 01 08:00:00 CST 1970, it's not the 00:00:00,but the 08:00:00,why?the result about the Date(long date)
You are using you using old date-time classes, now legacy, supplanted by the java.time classes.
Among its many problems, the
toString method of
java.util.Date implicitly applies the JVM’s current default time zone while generating a string. Avoid this class.
Instant. Represents a moment on the timeline in UTC with a resolution of nanoseconds.
Instant.ofEpochSecond( 0 ).toString()
Or use the constant for that value,
For current moment in UTC, call
To adjust into a specific time zone, search Stack Overflow for