TL;DR
ZonedDateTime.parse( // Parse string as `ZonedDateTime` object.
"1969-12-31T19:00-05:00[America/New_York]" // This zone on that date is five hours behind UTC.
) // So last day of 1969 at 7 PM there is simultaneously first moment of January 1, 1970 in UTC (00:00:00).
.toInstant() // .toString() --> 1970-01-01T00:00:00Z
.toEpochMilli() // --> zero seconds since epoch, as we are *at* the epoch.
0
Samuel .
java.time, , Date.
continent/region, America/Montreal, Africa/Casablanca Pacific/Auckland. 3-4 , EST IST, , (!).
ZoneId z = ZoneId.of( "Africa/Tunis" ) ;
ISO 8601
ISO 8601 .
java.time ISO 8601 / . .
ZonedDateTime , .
String input = "1970-01-01T05:30:01+05:30[Asia/Kolkata]" ;
ZonedDateTime zdt = ZonedDateTime.parse( input ) ;
String output = zdt.toString() ;
1970-01-01T05: 30: 01 + 05: 30 [/]
UTC, Instant. UTC, UTC.
Instant instant = zdt.toInstant() ;
instant.toString(): 1970-01-01T00: 00: 01Z
--, . , 1970 UTC (1970-01-01T00: 00: 00Z).
(1 ).
long millisSinceEpoch = instant.toEpochMilli() ;
1000
:
String input = "1970-01-01T10:00:00-05:00[America/New_York]"; // "Jan 01 10:00:00 EST 1970"
ZoneId z = ZoneId.of( "America/New_York" );
ZonedDateTime zdt = ZonedDateTime.parse( input );
Instant instant = zdt.toInstant();
long millisSinceEpoch = instant.toEpochMilli();
zdt.toString(): 1970-01-01T10: 00-05: 00 [America/New_York]
instant.toString(): 1970-01-01T15: 00: 00Z
millisSinceEpoch: 54000000
. 7 . America/New_York UTC. , UTC, , , 1970-01-01T00: 00: 00Z. , 1969-12-31T19:00-05:00[America/New_York] .
String input = "1969-12-31T19:00-05:00[America/New_York]" ;
ZoneId z = ZoneId.of( "America/New_York" );
ZonedDateTime zdt = ZonedDateTime.parse( input );
Instant instant = zdt.toInstant();
long millisSinceEpoch = instant.toEpochMilli();
zdt.toString(): 1969-12-31T19: 00-05: 00 [America/New_York]
instant.toString(): 1970-01-01T00: 00: 00Z
millisSinceEpoch: 0
java.time
java.time Java 8 . legacy , java.util.Date, Calendar SimpleDateFormat.
Joda-Time, , java.time.
, . Oracle. Qaru . JSR 310.
JDBC-, JDBC 4.2 java.time- . java.sql. * Classes.
java.time?
ThreeTen-Extra java.time . java.time. , Interval, YearWeek, YearQuarter .