Java Code Examples for sun.util.calendar.CalendarUtils#mod()

The following examples show how to use sun.util.calendar.CalendarUtils#mod() . 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 openjdk-jdk8u 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 2
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 3
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 4
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 5
Source File: Date.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 6
Source File: Date.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the <tt>Date</tt> constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>, using a UTC
 * <code>TimeZone</code>, followed by <code>Calendar.getTime().getTime()</code>.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 7
Source File: Date.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the <tt>Date</tt> constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>, using a UTC
 * <code>TimeZone</code>, followed by <code>Calendar.getTime().getTime()</code>.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 8
Source File: Date.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 9
Source File: Date.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the {@code Date} constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min, sec)}
 * or {@code GregorianCalendar(year + 1900, month, date, hrs, min, sec)}, using a UTC
 * {@code TimeZone}, followed by {@code Calendar.getTime().getTime()}.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 10
Source File: Date.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 11
Source File: Date.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 12
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a {@code Date} object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the {@code year}, {@code month}, {@code date},
 * {@code hrs}, {@code min}, and {@code sec} arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min, sec)}
 * or {@code GregorianCalendar(year + 1900, month, date, hrs, min, sec)}.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 13
Source File: Date.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 14
Source File: Date.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 15
Source File: Date.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the <tt>Date</tt> constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>, using a UTC
 * <code>TimeZone</code>, followed by <code>Calendar.getTime().getTime()</code>.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 16
Source File: Date.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 17
Source File: Date.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the <tt>Date</tt> constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>, using a UTC
 * <code>TimeZone</code>, followed by <code>Calendar.getTime().getTime()</code>.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 18
Source File: Date.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Allocates a <code>Date</code> object and initializes it so that
 * it represents the instant at the start of the second specified
 * by the <code>year</code>, <code>month</code>, <code>date</code>,
 * <code>hrs</code>, <code>min</code>, and <code>sec</code> arguments,
 * in the local time zone.
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>.
 */
@Deprecated
public Date(int year, int month, int date, int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    BaseCalendar cal = getCalendarSystem(y);
    cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
    cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
    getTimeImpl();
    cdate = null;
}
 
Example 19
Source File: Date.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the <tt>Date</tt> constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by <code>Calendar.set(year + 1900, month, date,
 * hrs, min, sec)</code> or <code>GregorianCalendar(year + 1900,
 * month, date, hrs, min, sec)</code>, using a UTC
 * <code>TimeZone</code>, followed by <code>Calendar.getTime().getTime()</code>.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}
 
Example 20
Source File: Date.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines the date and time based on the arguments. The
 * arguments are interpreted as a year, month, day of the month,
 * hour of the day, minute within the hour, and second within the
 * minute, exactly as for the {@code Date} constructor with six
 * arguments, except that the arguments are interpreted relative
 * to UTC rather than to the local time zone. The time indicated is
 * returned represented as the distance, measured in milliseconds,
 * of that time from the epoch (00:00:00 GMT on January 1, 1970).
 *
 * @param   year    the year minus 1900.
 * @param   month   the month between 0-11.
 * @param   date    the day of the month between 1-31.
 * @param   hrs     the hours between 0-23.
 * @param   min     the minutes between 0-59.
 * @param   sec     the seconds between 0-59.
 * @return  the number of milliseconds since January 1, 1970, 00:00:00 GMT for
 *          the date and time specified by the arguments.
 * @see     java.util.Calendar
 * @deprecated As of JDK version 1.1,
 * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min, sec)}
 * or {@code GregorianCalendar(year + 1900, month, date, hrs, min, sec)}, using a UTC
 * {@code TimeZone}, followed by {@code Calendar.getTime().getTime()}.
 */
@Deprecated
public static long UTC(int year, int month, int date,
                       int hrs, int min, int sec) {
    int y = year + 1900;
    // month is 0-based. So we have to normalize month to support Long.MAX_VALUE.
    if (month >= 12) {
        y += month / 12;
        month %= 12;
    } else if (month < 0) {
        y += CalendarUtils.floorDivide(month, 12);
        month = CalendarUtils.mod(month, 12);
    }
    int m = month + 1;
    BaseCalendar cal = getCalendarSystem(y);
    BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
    udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);

    // Use a Date instance to perform normalization. Its fastTime
    // is the UTC value after the normalization.
    Date d = new Date(0);
    d.normalize(udate);
    return d.fastTime;
}