java.time
Never use the legacy class Date
. Do not waste your time trying to understand the awful mess that is Date
and Calendar
.
Use only the modern java.time classes. Later versions of Jackson support java.time.
OffsetDateTime odt = OffsetDateTime.parse( "1911-01-01T00:00:00+00:00" ) ;
When asked to produce text representing its value, that OffsetDateTime
generates:
odt.toString(): 1911-01-01T00:00Z
The Z
on the end means an offset of zero hours-minutes-seconds from UTC, and is pronounced “Zulu”.
For an explanation as to what happened with your code using the legacy classes, see the excellent Answer by Ole V.V. But notice that using the properly-designed classes in java.time avoids the underlying issue: Applying a time zone where none was called for.
A time zone is a history of the past, present, and future changes to the offset used by the people of a particular region. Your input carries an offset (of zero), with no indication of time zone. So no need to involve a time zone in processing your input.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…