Example usage for org.joda.time DateTimeZone getProvider

List of usage examples for org.joda.time DateTimeZone getProvider

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone getProvider.

Prototype

public static Provider getProvider() 

Source Link

Document

Gets the zone provider factory.

Usage

From source file:com.foundationdb.server.service.config.ConfigurationServiceImpl.java

License:Open Source License

private void validateTimeZone() {
    String timezone = System.getProperty("user.timezone");
    // The goal here is to make sure that if the user sets user.timezone we will parse it correctly and not end up
    // in a situation where DateTimeZone is inconsistent with TimeZone, or where it just defaulted to UTC because
    // the user did "-Duser.timezone=America/Los_angeles" (note the lower case a).
    // There are other cases where it would work, such as "-Duser.timezone=PST", but PST isn't a valid timezone
    // according to DateTimeZone, so we will stop, even though it would technically work. That's ok though, because
    // PST is just there for java 1.1.x compatibility.

    // Note also that in the open jdk for 1.7u and 1.8 (at least) there's a bug on Mac OS X where if you specify
    // an invalid user.timezone, it will end up being GMT}05:00 where the 05:00 is your system time, and the } is
    // an unprintable character. I filed a bug though, so that might get fixed.

    // Also note, that, as of this writing, there are usages of both java.util date functionality and Joda
    if (timezone != null && timezone.length() != 0 && DateTimeZone.getProvider().getZone(timezone) == null) {
        // Originally a hard error but JRE on CentOS 6 found to consistently misuse /etc/sysconfig/clock
        // throw new InvalidTimeZoneException();
        LOG.error("Reverting to timezone {} as Joda does not support user.timezone={}",
                DateTimeZone.getDefault(), timezone);
    } else {/*from ww w .j  a  v a  2s .  c o  m*/
        LOG.debug("Using timezone: {}", DateTimeZone.getDefault());
    }
}