San Antonio → America/Chicago
The IANA time zone identifier for San Antonio is America/Chicago
, as shown on Time.is.
Using java.time
The modern way to handle date-time is with the java.time classes.
The Instant
class represents a moment on the timeline in UTC with a resolution of nanoseconds.
Instant instant = Instant.now(); // Current moment in UTC.
Apply a ZoneId
to get a ZonedDateTime
.
ZoneId z = ZoneId.of( "America/Chicago" );
ZonedDateTime zdt = instant.atZone( z );
Avoid 3-4 letter zone abbreviations
Specify a proper time zone name in the format of continent/region
such as America/Montreal
, Africa/Casablanca
, or Pacific/Auckland
.
Never use the 3-4 letter abbreviation such as EST
or IST
or PST
as they are not true time zones, not standardized, and not even unique(!).
The time zone name is often a city. This naming is not meant literally to be just that city. Such naming is simply a way to label a region whose inhabitants have a shared history of the same time zone rules. That region may be quite large if the entire swath of land has always been populated by people sharing the same set of rules.
About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.