Skip to content

Instantly share code, notes, and snippets.

@jarrodhroberson
Created July 21, 2015 19:56
Show Gist options
  • Save jarrodhroberson/dfb72f1b7e407c19ab77 to your computer and use it in GitHub Desktop.
Save jarrodhroberson/dfb72f1b7e407c19ab77 to your computer and use it in GitHub Desktop.
Dump TimeZone Information with an example of the current time in ISO8601 FULL
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import javax.annotation.Nonnull;
public class TimeZoneInfo
{
public static void main(@Nonnull final String[] args)
{
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
final Date now = new Date();
System.out.println("ID (DISPLAY NAME) EXAMPLE");
for (final String id : TimeZone.getAvailableIDs())
{
final TimeZone tz = TimeZone.getTimeZone(id);
sdf.setTimeZone(tz);
System.out.println(String.format("%s (%s) %s",id, tz.getDisplayName(), sdf.format(now)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment