Java Code Examples for java.util.SimpleTimeZone#inDaylightTime()

The following examples show how to use java.util.SimpleTimeZone#inDaylightTime() . 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: ZoneInfo.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    } else {
        // use the last transition
        return (transitions[transitions.length - 1] & DST_MASK) != 0;
    }
}
 
Example 2
Source File: ZoneInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 3
Source File: ZoneInfoOld.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 4
Source File: ZoneInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 5
Source File: ZoneInfoOld.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 6
Source File: ZoneInfo.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 7
Source File: ZoneInfoOld.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 8
Source File: ZoneInfoOld.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 9
Source File: ZoneInfo.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 10
Source File: ZoneInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 11
Source File: ZoneInfoOld.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 12
Source File: ZoneInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 13
Source File: ZoneInfoOld.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 14
Source File: ZoneInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 15
Source File: ZoneInfo.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 16
Source File: ZoneInfoOld.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 17
Source File: ZoneInfoOld.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 18
Source File: ZoneInfo.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
   }
    return false;
}
 
Example 19
Source File: ZoneInfoOld.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Queries if the specified date is in Daylight Saving Time.
 */
public boolean inDaylightTime(Date date) {
    if (date == null) {
        throw new NullPointerException();
    }

    if (transitions == null) {
        return false;
    }

    long utc = date.getTime() - rawOffsetDiff;
    int index = getTransitionIndex(utc, UTC_TIME);

    // before transitions in the transition table
    if (index < 0) {
        return false;
    }

    // the time is in the table range.
    if (index < transitions.length) {
        return (transitions[index] & DST_MASK) != 0;
    }

    // beyond the transition table
    SimpleTimeZone tz = getLastRule();
    if (tz != null) {
        return tz.inDaylightTime(date);
    }
    return false;
}
 
Example 20
Source File: TimeZoneTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
public void test_clone_SimpleTimeZone() {
    SimpleTimeZone stz = new SimpleTimeZone(21600000, "Central Standard Time");
    stz.setStartYear(1000);
    stz.inDaylightTime(new Date());
    stz.clone();
}