< prev index next >

src/java.base/share/classes/sun/util/calendar/ZoneInfo.java

Print this page




 347 
 348    /**
 349      * Returns the difference in milliseconds between local time and
 350      * UTC, taking into account both the raw offset and the effect of
 351      * daylight savings, for the specified date and time.  This method
 352      * assumes that the start and end month are distinct.  This method
 353      * assumes a Gregorian calendar for calculations.
 354      * <p>
 355      * <em>Note: In general, clients should use
 356      * {@link Calendar#ZONE_OFFSET Calendar.get(ZONE_OFFSET)} +
 357      * {@link Calendar#DST_OFFSET Calendar.get(DST_OFFSET)}
 358      * instead of calling this method.</em>
 359      *
 360      * @param era       The era of the given date. The value must be either
 361      *                  GregorianCalendar.AD or GregorianCalendar.BC.
 362      * @param year      The year in the given date.
 363      * @param month     The month in the given date. Month is 0-based. e.g.,
 364      *                  0 for January.
 365      * @param day       The day-in-month of the given date.
 366      * @param dayOfWeek The day-of-week of the given date.
 367      * @param millis    The milliseconds in day in <em>standard</em> local time.
 368      * @return The milliseconds to add to UTC to get local time.
 369      */
 370     public int getOffset(int era, int year, int month, int day,
 371                          int dayOfWeek, int milliseconds) {
 372         if (milliseconds < 0 || milliseconds >= AbstractCalendar.DAY_IN_MILLIS) {
 373             throw new IllegalArgumentException();
 374         }
 375 
 376         if (era == java.util.GregorianCalendar.BC) { // BC
 377             year = 1 - year;
 378         } else if (era != java.util.GregorianCalendar.AD) {
 379             throw new IllegalArgumentException();
 380         }
 381 
 382         CalendarDate date = gcal.newCalendarDate(null);
 383         date.setDate(year, month + 1, day);
 384         if (gcal.validate(date) == false) {
 385             throw new IllegalArgumentException();
 386         }
 387 




 347 
 348    /**
 349      * Returns the difference in milliseconds between local time and
 350      * UTC, taking into account both the raw offset and the effect of
 351      * daylight savings, for the specified date and time.  This method
 352      * assumes that the start and end month are distinct.  This method
 353      * assumes a Gregorian calendar for calculations.
 354      * <p>
 355      * <em>Note: In general, clients should use
 356      * {@link Calendar#ZONE_OFFSET Calendar.get(ZONE_OFFSET)} +
 357      * {@link Calendar#DST_OFFSET Calendar.get(DST_OFFSET)}
 358      * instead of calling this method.</em>
 359      *
 360      * @param era       The era of the given date. The value must be either
 361      *                  GregorianCalendar.AD or GregorianCalendar.BC.
 362      * @param year      The year in the given date.
 363      * @param month     The month in the given date. Month is 0-based. e.g.,
 364      *                  0 for January.
 365      * @param day       The day-in-month of the given date.
 366      * @param dayOfWeek The day-of-week of the given date.
 367      * @param milliseconds The milliseconds in day in <em>standard</em> local time.
 368      * @return The milliseconds to add to UTC to get local time.
 369      */
 370     public int getOffset(int era, int year, int month, int day,
 371                          int dayOfWeek, int milliseconds) {
 372         if (milliseconds < 0 || milliseconds >= AbstractCalendar.DAY_IN_MILLIS) {
 373             throw new IllegalArgumentException();
 374         }
 375 
 376         if (era == java.util.GregorianCalendar.BC) { // BC
 377             year = 1 - year;
 378         } else if (era != java.util.GregorianCalendar.AD) {
 379             throw new IllegalArgumentException();
 380         }
 381 
 382         CalendarDate date = gcal.newCalendarDate(null);
 383         date.setDate(year, month + 1, day);
 384         if (gcal.validate(date) == false) {
 385             throw new IllegalArgumentException();
 386         }
 387 


< prev index next >