sun.util.calendar.CalendarUtils Java Examples

The following examples show how to use sun.util.calendar.CalendarUtils. 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: Date.java    From jdk8u60 with GNU General Public License v2.0 7 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #2
Source File: Date.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #3
Source File: Date.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #4
Source File: Date.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #5
Source File: CalendarAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
String toTimeString() {
    StringBuffer sb = new StringBuffer();
    CalendarUtils.sprintf0d(sb, cal.get(HOUR_OF_DAY), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(MINUTE), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(SECOND),2 ).append('.');
    CalendarUtils.sprintf0d(sb, cal.get(MILLISECOND), 3);
    int zoneOffset = cal.get(ZONE_OFFSET) + cal.get(DST_OFFSET);
    if (zoneOffset == 0) {
        sb.append('Z');
    } else {
        int offset;
        char sign;
        if (zoneOffset > 0) {
            offset = zoneOffset;
            sign = '+';
        } else {
            offset = -zoneOffset;
            sign = '-';
        }
        offset /= 60000;
        sb.append(sign);
        CalendarUtils.sprintf0d(sb, offset / 60, 2);
        CalendarUtils.sprintf0d(sb, offset % 60, 2);
    }
    return sb.toString();
}
 
Example #6
Source File: CalendarAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
String toTimeString() {
    StringBuffer sb = new StringBuffer();
    CalendarUtils.sprintf0d(sb, cal.get(HOUR_OF_DAY), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(MINUTE), 2).append(':');
    CalendarUtils.sprintf0d(sb, cal.get(SECOND),2 ).append('.');
    CalendarUtils.sprintf0d(sb, cal.get(MILLISECOND), 3);
    int zoneOffset = cal.get(ZONE_OFFSET) + cal.get(DST_OFFSET);
    if (zoneOffset == 0) {
        sb.append('Z');
    } else {
        int offset;
        char sign;
        if (zoneOffset > 0) {
            offset = zoneOffset;
            sign = '+';
        } else {
            offset = -zoneOffset;
            sign = '-';
        }
        offset /= 60000;
        sb.append(sign);
        CalendarUtils.sprintf0d(sb, offset / 60, 2);
        CalendarUtils.sprintf0d(sb, offset % 60, 2);
    }
    return sb.toString();
}
 
Example #7
Source File: Date.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #8
Source File: Date.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #9
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * {@code Date} object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by {@code Calendar.set(Calendar.MONTH, int month)}.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #10
Source File: Date.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #11
Source File: Date.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #12
Source File: Date.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #13
Source File: Date.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #14
Source File: Date.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #15
Source File: Date.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #16
Source File: Date.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the month of this date to the specified value. This
 * <tt>Date</tt> object is modified so that it represents a point
 * in time within the specified month, with the year, date, hour,
 * minute, and second the same as before, as interpreted in the
 * local time zone. If the date was October 31, for example, and
 * the month is set to June, then the new date will be treated as
 * if it were on July 1, because June has only 30 days.
 *
 * @param   month   the month value between 0-11.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
 */
@Deprecated
public void setMonth(int month) {
    int y = 0;
    if (month >= 12) {
        y = month / 12;
        month %= 12;
    } else if (month < 0) {
        y = CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar.Date d = getCalendarDate();
    if (y != 0) {
        d.setNormalizedYear(d.getNormalizedYear() + y);
    }
    d.setMonth(month + 1); // adjust 0-based to 1-based month numbering
}
 
Example #17
Source File: GregorianCalendar.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #18
Source File: CalendarAdapter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
String toDateString() {
    StringBuffer sb = new StringBuffer();
    String[] eraNames = null;
    switch (type) {
    case GREGORIAN:
        eraNames = new String[] { "BCE", "" };
        break;

    case BUDDHIST:
        eraNames = new String[] { "Before BE", "BE"};
        break;

    case JAPANESE:
        eraNames = new String[] {
            "BeforeMeiji",
            "Meiji",
            "Taisho",
            "Showa",
            "Heisei",
            "Reiwa"
        };
        break;
    }

    sb.append(eraNames[cal.get(ERA)]);
    if (sb.length() > 0)
        sb.append(' ');
    CalendarUtils.sprintf0d(sb, cal.get(YEAR), 4).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(MONTH)+1, 2).append('-');
    CalendarUtils.sprintf0d(sb, cal.get(DAY_OF_MONTH), 2);
    return sb.toString();
}
 
Example #19
Source File: GregorianCalendar.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #20
Source File: GregorianCalendar.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #21
Source File: GregorianCalendar.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar jcal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
    jcal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #22
Source File: GregorianCalendar.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #23
Source File: GregorianCalendar.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #24
Source File: GregorianCalendar.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #25
Source File: GregorianCalendar.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #26
Source File: GregorianCalendar.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #27
Source File: GregorianCalendar.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #28
Source File: GregorianCalendar.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #29
Source File: GregorianCalendar.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}
 
Example #30
Source File: GregorianCalendar.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void setGregorianChange(long cutoverTime) {
    gregorianCutover = cutoverTime;
    gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY)
                            + EPOCH_OFFSET;

    // To provide the "pure" Julian calendar as advertised.
    // Strictly speaking, the last millisecond should be a
    // Gregorian date. However, the API doc specifies that setting
    // the cutover date to Long.MAX_VALUE will make this calendar
    // a pure Julian calendar. (See 4167995)
    if (cutoverTime == Long.MAX_VALUE) {
        gregorianCutoverDate++;
    }

    BaseCalendar.Date d = getGregorianCutoverDate();

    // Set the cutover year (in the Gregorian year numbering)
    gregorianCutoverYear = d.getYear();

    BaseCalendar julianCal = getJulianCalendarSystem();
    d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
    julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
    gregorianCutoverYearJulian = d.getNormalizedYear();

    if (time < gregorianCutover) {
        // The field values are no longer valid under the new
        // cutover date.
        setUnnormalized();
    }
}