:
Instant.EPOCH
.toString()
1970-01-01T00: 00: 00Z
Date::toString
java.util.Date/Calendar: Date , toString . , , , .
Date/Calendar
/ Joda-Time Java 8, java.time. * JSR 310.
java.time
Instant Date, UTC.
Instant.now()
.
Instant.EPOCH.toString()
1970-01-01T00: 00: 00Z
" " , , LocalDate.
LocalDate.ofEpochDay( 0L )
1970-01-01
Joda
. Joda-Time , java.time.
Joda-Time DateTime . , .
, Unix time Epoch, Joda-Time 2.3.
DateTimeZone timeZone_Paris = DateTimeZone.forID( "Europe/Paris" );
DateTime epochParis = new DateTime( 0L, timeZone_Paris );
DateTime epochUtc = new DateTime( 0L, DateTimeZone.UTC );
...
System.out.println( "epochParis: " + epochParis );
System.out.println( "epochUtc: " + epochUtc );
...
epochParis: 1970-01-01T01:00:00.000+01:00
epochUtc: 1970-01-01T00:00:00.000Z
UTC/GMT
, GMT ?
UTC/GMT ( ):
- Convert DateTime to another instance with a different time zone
(Joda-Time makes things unchanged for thread safety, so we donโt actually convert, we create new instances based on the old ones.) - Use the formatter to create lines displayed for a specific time zone.
DateTime nowInParis = new DateTime( timeZone_Paris );
DateTime nowInUtcGmt = nowInParis.toDateTime( DateTimeZone.UTC );
Dump for console ...
System.out.println( "nowInParis: " + nowInParis );
System.out.println( "nowInUtcGmt: " + nowInUtcGmt );
At startup ...
nowInParis: 2013-12-22T08:40:01.443+01:00
nowInUtcGmt: 2013-12-22T07:40:01.443Z
source
share