Java Code Examples for org.joda.time.DateTimeZone#getStandardOffset()

The following examples show how to use org.joda.time.DateTimeZone#getStandardOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeZoneInfo.java    From es6draft with MIT License 6 votes vote down vote up
@Override
public int getRawOffset(TimeZone tz, long date) {
    DateTimeZone timeZone = toDateTimeZone(tz);
    if (IGNORE_LOCAL_BEFORE_EPOCH) {
        if (date < EPOCH) {
            date = toFirstDateWithNormalizedTime(timeZone, date);
        }
    } else if (IGNORE_LOCAL) {
        if (date <= LAST_LOCAL_TRANSITION) {
            date = toFirstDateWithNormalizedTime(timeZone, date);
        }
    } else if (IGNORE_LMT) {
        if (date <= LAST_LMT_TRANSITION) {
            date = toFirstDateAfterLocalMeanTime(timeZone, date);
        }
    }
    return timeZone.getStandardOffset(date);
}
 
Example 2
Source File: TestHiveUtil.java    From presto with Apache License 2.0 5 votes vote down vote up
public static DateTimeZone nonDefaultTimeZone()
{
    String defaultId = DateTimeZone.getDefault().getID();
    for (String id : DateTimeZone.getAvailableIDs()) {
        if (!id.equals(defaultId)) {
            DateTimeZone zone = DateTimeZone.forID(id);
            if (zone.getStandardOffset(0) != 0) {
                return zone;
            }
        }
    }
    throw new IllegalStateException("no non-default timezone");
}
 
Example 3
Source File: TimeZoneInfo.java    From es6draft with MIT License 5 votes vote down vote up
@Override
public String getDisplayName(TimeZone tz, long date) {
    DateTimeZone timeZone = toDateTimeZone(tz);
    if (IGNORE_LOCAL_BEFORE_EPOCH) {
        if (date < EPOCH) {
            date = toFirstDateWithNormalizedTime(timeZone, date);
        }
    } else if (IGNORE_LOCAL) {
        if (date <= LAST_LOCAL_TRANSITION) {
            date = toFirstDateWithNormalizedTime(timeZone, date);
        }
    } else if (IGNORE_LMT) {
        if (date <= LAST_LMT_TRANSITION) {
            date = toFirstDateAfterLocalMeanTime(timeZone, date);
        }
    }
    String displayName = timeZone.getNameKey(date);
    if (displayName != null) {
        return displayName;
    }
    boolean daylightSavings = !timeZone.isStandardOffset(date);
    if (!daylightSavings
            && timeZone.getOffset(date) != timeZone.getStandardOffset(System.currentTimeMillis())) {
        daylightSavings = timeZone.nextTransition(date) != date;
    }
    return tz.getDisplayName(daylightSavings, TimeZone.SHORT, Locale.US);
}