mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
6453901: (cal) clean up sun.util.calendar classes
Reviewed-by: naoto, lancea
This commit is contained in:
parent
acf899612f
commit
f1f4e1de44
10 changed files with 29 additions and 210 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
package sun.util.calendar;
|
package sun.util.calendar;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,20 +80,6 @@ public abstract class AbstractCalendar extends CalendarSystem {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEra(CalendarDate date, String eraName) {
|
|
||||||
if (eras == null) {
|
|
||||||
return; // should report an error???
|
|
||||||
}
|
|
||||||
for (int i = 0; i < eras.length; i++) {
|
|
||||||
Era e = eras[i];
|
|
||||||
if (e != null && e.getName().equals(eraName)) {
|
|
||||||
date.setEra(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("unknown era name: " + eraName);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setEras(Era[] eras) {
|
protected void setEras(Era[] eras) {
|
||||||
this.eras = eras;
|
this.eras = eras;
|
||||||
}
|
}
|
||||||
|
@ -258,15 +243,6 @@ public abstract class AbstractCalendar extends CalendarSystem {
|
||||||
return cdate;
|
return cdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns 7 in this default implementation.
|
|
||||||
*
|
|
||||||
* @return 7
|
|
||||||
*/
|
|
||||||
public int getWeekLength() {
|
|
||||||
return 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract boolean isLeapYear(CalendarDate date);
|
protected abstract boolean isLeapYear(CalendarDate date);
|
||||||
|
|
||||||
public CalendarDate getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date) {
|
public CalendarDate getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date) {
|
||||||
|
@ -341,7 +317,7 @@ public abstract class AbstractCalendar extends CalendarSystem {
|
||||||
* method stores the calculated calendar field values in the specified
|
* method stores the calculated calendar field values in the specified
|
||||||
* <code>CalendarDate</code>.
|
* <code>CalendarDate</code>.
|
||||||
*
|
*
|
||||||
* @param date a <code>CalendarDate</code> to stored the
|
* @param date a <code>CalendarDate</code> to store the
|
||||||
* calculated calendar fields.
|
* calculated calendar fields.
|
||||||
* @param fixedDate a fixed date to calculate calendar fields
|
* @param fixedDate a fixed date to calculate calendar fields
|
||||||
* @see AbstractCalendar.html#fixed_date
|
* @see AbstractCalendar.html#fixed_date
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -307,10 +307,6 @@ public abstract class BaseCalendar extends AbstractCalendar {
|
||||||
return isLeapYear(((Date)date).getNormalizedYear()) ? 366 : 365;
|
return isLeapYear(((Date)date).getNormalizedYear()) ? 366 : 365;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getYearLengthInMonths(CalendarDate date) {
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
static final int[] DAYS_IN_MONTH
|
static final int[] DAYS_IN_MONTH
|
||||||
// 12 1 2 3 4 5 6 7 8 9 10 11 12
|
// 12 1 2 3 4 5 6 7 8 9 10 11 12
|
||||||
= { 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
= { 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||||
|
@ -527,7 +523,7 @@ public abstract class BaseCalendar extends AbstractCalendar {
|
||||||
/**
|
/**
|
||||||
* @return true if the specified year is a Gregorian leap year, or
|
* @return true if the specified year is a Gregorian leap year, or
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
* @see BaseCalendar#isGregorianLeapYear
|
* @see CalendarUtils#isGregorianLeapYear
|
||||||
*/
|
*/
|
||||||
protected boolean isLeapYear(CalendarDate date) {
|
protected boolean isLeapYear(CalendarDate date) {
|
||||||
return isLeapYear(((Date)date).getNormalizedYear());
|
return isLeapYear(((Date)date).getNormalizedYear());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -152,7 +152,7 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
* @return <code>true</code> if this <code>CalendarDate</code> is
|
* @return <code>true</code> if this <code>CalendarDate</code> is
|
||||||
* normalized and the year of this <code>CalendarDate</code> is a
|
* normalized and the year of this <code>CalendarDate</code> is a
|
||||||
* leap year, or <code>false</code> otherwise.
|
* leap year, or <code>false</code> otherwise.
|
||||||
* @see BaseCalendar#isGregorianLeapYear
|
* @see CalendarUtils#isGregorianLeapYear
|
||||||
*/
|
*/
|
||||||
public boolean isLeapYear() {
|
public boolean isLeapYear() {
|
||||||
return leapYear;
|
return leapYear;
|
||||||
|
@ -194,14 +194,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addDayOfMonth(int n) {
|
|
||||||
if (n != 0) {
|
|
||||||
dayOfMonth += n;
|
|
||||||
normalized = false;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the day of week value. If this CalendarDate is not
|
* Returns the day of week value. If this CalendarDate is not
|
||||||
* normalized, {@link #FIELD_UNDEFINED} is returned.
|
* normalized, {@link #FIELD_UNDEFINED} is returned.
|
||||||
|
@ -247,14 +239,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addMinutes(int n) {
|
|
||||||
if (n != 0) {
|
|
||||||
minutes += n;
|
|
||||||
normalized = false;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSeconds() {
|
public int getSeconds() {
|
||||||
return seconds;
|
return seconds;
|
||||||
}
|
}
|
||||||
|
@ -267,14 +251,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addSeconds(int n) {
|
|
||||||
if (n != 0) {
|
|
||||||
seconds += n;
|
|
||||||
normalized = false;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMillis() {
|
public int getMillis() {
|
||||||
return millis;
|
return millis;
|
||||||
}
|
}
|
||||||
|
@ -287,14 +263,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addMillis(int n) {
|
|
||||||
if (n != 0) {
|
|
||||||
millis += n;
|
|
||||||
normalized = false;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeOfDay() {
|
public long getTimeOfDay() {
|
||||||
if (!isNormalized()) {
|
if (!isNormalized()) {
|
||||||
return fraction = TIME_UNDEFINED;
|
return fraction = TIME_UNDEFINED;
|
||||||
|
@ -309,13 +277,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addDate(int year, int month, int dayOfMonth) {
|
|
||||||
addYear(year);
|
|
||||||
addMonth(month);
|
|
||||||
addDayOfMonth(dayOfMonth);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
||||||
setHours(hours);
|
setHours(hours);
|
||||||
setMinutes(minutes);
|
setMinutes(minutes);
|
||||||
|
@ -324,14 +285,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
|
||||||
addHours(hours);
|
|
||||||
addMinutes(minutes);
|
|
||||||
addSeconds(seconds);
|
|
||||||
addMillis(millis);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTimeOfDay(long fraction) {
|
protected void setTimeOfDay(long fraction) {
|
||||||
this.fraction = fraction;
|
this.fraction = fraction;
|
||||||
}
|
}
|
||||||
|
@ -345,10 +298,6 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
return forceStandardTime;
|
return forceStandardTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStandardTime(boolean standardTime) {
|
|
||||||
forceStandardTime = standardTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDaylightTime() {
|
public boolean isDaylightTime() {
|
||||||
if (isStandardTime()) {
|
if (isStandardTime()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -382,10 +331,9 @@ public abstract class CalendarDate implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof CalendarDate)) {
|
if (!(obj instanceof CalendarDate that)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CalendarDate that = (CalendarDate) obj;
|
|
||||||
if (isNormalized() != that.isNormalized()) {
|
if (isNormalized() != that.isNormalized()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -234,14 +234,6 @@ public abstract class CalendarSystem {
|
||||||
*/
|
*/
|
||||||
public abstract int getYearLength(CalendarDate date);
|
public abstract int getYearLength(CalendarDate date);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of months of the specified year. This method
|
|
||||||
* does not perform the normalization with the specified
|
|
||||||
* <code>CalendarDate</code>. The <code>CalendarDate</code> must
|
|
||||||
* be normalized to get a correct value.
|
|
||||||
*/
|
|
||||||
public abstract int getYearLengthInMonths(CalendarDate date);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length in days of the month specified by the calendar
|
* Returns the length in days of the month specified by the calendar
|
||||||
* date. This method does not perform the normalization with the
|
* date. This method does not perform the normalization with the
|
||||||
|
@ -255,13 +247,6 @@ public abstract class CalendarSystem {
|
||||||
*/
|
*/
|
||||||
public abstract int getMonthLength(CalendarDate date); // no setter
|
public abstract int getMonthLength(CalendarDate date); // no setter
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the length in days of a week in this calendar
|
|
||||||
* system. If this calendar system has multiple radix weeks, this
|
|
||||||
* method returns only one of them.
|
|
||||||
*/
|
|
||||||
public abstract int getWeekLength();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the <code>Era</code> designated by the era name that
|
* Returns the <code>Era</code> designated by the era name that
|
||||||
* has to be known to this calendar system. If no Era is
|
* has to be known to this calendar system. If no Era is
|
||||||
|
@ -287,13 +272,6 @@ public abstract class CalendarSystem {
|
||||||
*/
|
*/
|
||||||
public abstract Era[] getEras();
|
public abstract Era[] getEras();
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws IllegalArgumentException if the specified era name is
|
|
||||||
* unknown to this calendar system.
|
|
||||||
* @see Era
|
|
||||||
*/
|
|
||||||
public abstract void setEra(CalendarDate date, String eraName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a <code>CalendarDate</code> of the n-th day of week
|
* Returns a <code>CalendarDate</code> of the n-th day of week
|
||||||
* which is on, after or before the specified date. For example, the
|
* which is on, after or before the specified date. For example, the
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -25,9 +25,6 @@
|
||||||
|
|
||||||
package sun.util.calendar;
|
package sun.util.calendar;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CalendarUtils {
|
public class CalendarUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,29 +106,6 @@ public class CalendarUtils {
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Divides two integers and returns the floor of the quotient and
|
|
||||||
* the modulus remainder. For example,
|
|
||||||
* <code>floorDivide(-1,4)</code> returns <code>-1</code> with
|
|
||||||
* <code>3</code> as its remainder, while <code>-1/4</code> is
|
|
||||||
* <code>0</code> and <code>-1%4</code> is <code>-1</code>.
|
|
||||||
*
|
|
||||||
* @param n the numerator
|
|
||||||
* @param d a divisor which must be {@literal > 0}
|
|
||||||
* @param r an array of at least one element in which the value
|
|
||||||
* <code>mod(n, d)</code> is returned.
|
|
||||||
* @return the floor of the quotient.
|
|
||||||
*/
|
|
||||||
public static final int floorDivide(long n, int d, int[] r) {
|
|
||||||
if (n >= 0) {
|
|
||||||
r[0] = (int)(n % d);
|
|
||||||
return (int)(n / d);
|
|
||||||
}
|
|
||||||
int q = (int)(((n + 1) / d) - 1);
|
|
||||||
r[0] = (int)(n - (q * d));
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final long mod(long x, long y) {
|
public static final long mod(long x, long y) {
|
||||||
return (x - y * floorDivide(x, y));
|
return (x - y * floorDivide(x, y));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -79,9 +79,9 @@ public final class Era {
|
||||||
this.abbr = abbr;
|
this.abbr = abbr;
|
||||||
this.since = since;
|
this.since = since;
|
||||||
this.localTime = localTime;
|
this.localTime = localTime;
|
||||||
Gregorian gcal = CalendarSystem.getGregorianCalendar();
|
Gregorian gCal = CalendarSystem.getGregorianCalendar();
|
||||||
BaseCalendar.Date d = gcal.newCalendarDate(null);
|
BaseCalendar.Date d = gCal.newCalendarDate(null);
|
||||||
gcal.getCalendarDate(since, d);
|
gCal.getCalendarDate(since, d);
|
||||||
sinceDate = new ImmutableGregorianDate(d);
|
sinceDate = new ImmutableGregorianDate(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,6 @@ public final class Era {
|
||||||
return abbr;
|
return abbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiaplayAbbreviation(Locale locale) {
|
|
||||||
return abbr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSince(TimeZone zone) {
|
public long getSince(TimeZone zone) {
|
||||||
if (zone == null || !localTime) {
|
if (zone == null || !localTime) {
|
||||||
return since;
|
return since;
|
||||||
|
@ -118,10 +114,9 @@ public final class Era {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!(o instanceof Era)) {
|
if (!(o instanceof Era that)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Era that = (Era) o;
|
|
||||||
return name.equals(that.name)
|
return name.equals(that.name)
|
||||||
&& abbr.equals(that.abbr)
|
&& abbr.equals(that.abbr)
|
||||||
&& since == that.since
|
&& since == that.since
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -86,10 +86,6 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addDayOfMonth(int n) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDayOfWeek() {
|
public int getDayOfWeek() {
|
||||||
return date.getDayOfWeek();
|
return date.getDayOfWeek();
|
||||||
}
|
}
|
||||||
|
@ -114,10 +110,6 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addMinutes(int n) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSeconds() {
|
public int getSeconds() {
|
||||||
return date.getSeconds();
|
return date.getSeconds();
|
||||||
}
|
}
|
||||||
|
@ -126,10 +118,6 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addSeconds(int n) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMillis() {
|
public int getMillis() {
|
||||||
return date.getMillis();
|
return date.getMillis();
|
||||||
}
|
}
|
||||||
|
@ -138,10 +126,6 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addMillis(int n) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeOfDay() {
|
public long getTimeOfDay() {
|
||||||
return date.getTimeOfDay();
|
return date.getTimeOfDay();
|
||||||
}
|
}
|
||||||
|
@ -150,18 +134,10 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addDate(int year, int month, int dayOfMonth) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
||||||
unsupported(); return this;
|
unsupported(); return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarDate addTimeOfDay(int hours, int minutes, int seconds, int millis) {
|
|
||||||
unsupported(); return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTimeOfDay(long fraction) {
|
protected void setTimeOfDay(long fraction) {
|
||||||
unsupported();
|
unsupported();
|
||||||
}
|
}
|
||||||
|
@ -174,10 +150,6 @@ class ImmutableGregorianDate extends BaseCalendar.Date {
|
||||||
return date.isStandardTime();
|
return date.isStandardTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStandardTime(boolean standardTime) {
|
|
||||||
unsupported();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDaylightTime() {
|
public boolean isDaylightTime() {
|
||||||
return date.isDaylightTime();
|
return date.isDaylightTime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
package sun.util.calendar;
|
package sun.util.calendar;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -70,7 +70,6 @@ public class ZoneInfo extends TimeZone {
|
||||||
private static final long DST_MASK = 0xf0L;
|
private static final long DST_MASK = 0xf0L;
|
||||||
private static final int DST_NSHIFT = 4;
|
private static final int DST_NSHIFT = 4;
|
||||||
// this bit field is reserved for abbreviation support
|
// this bit field is reserved for abbreviation support
|
||||||
private static final long ABBR_MASK = 0xf00L;
|
|
||||||
private static final int TRANSITION_NSHIFT = 12;
|
private static final int TRANSITION_NSHIFT = 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,7 +393,7 @@ public class ZoneInfo extends TimeZone {
|
||||||
}
|
}
|
||||||
|
|
||||||
long dateInMillis = gcal.getTime(date) + milliseconds;
|
long dateInMillis = gcal.getTime(date) + milliseconds;
|
||||||
dateInMillis -= (long) rawOffset; // make it UTC
|
dateInMillis -= rawOffset; // make it UTC
|
||||||
return getOffsets(dateInMillis, null, UTC_TIME);
|
return getOffsets(dateInMillis, null, UTC_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,7 +403,7 @@ public class ZoneInfo extends TimeZone {
|
||||||
* historical ones, if applicable.
|
* historical ones, if applicable.
|
||||||
*
|
*
|
||||||
* @param offsetMillis the base time zone offset to GMT.
|
* @param offsetMillis the base time zone offset to GMT.
|
||||||
* @see getRawOffset
|
* @see #getRawOffset
|
||||||
*/
|
*/
|
||||||
public synchronized void setRawOffset(int offsetMillis) {
|
public synchronized void setRawOffset(int offsetMillis) {
|
||||||
if (offsetMillis == rawOffset + rawOffsetDiff) {
|
if (offsetMillis == rawOffset + rawOffsetDiff) {
|
||||||
|
@ -525,20 +524,6 @@ public class ZoneInfo extends TimeZone {
|
||||||
return dstSavings;
|
return dstSavings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return the last year in the transition table or -1 if this
|
|
||||||
// * time zone doesn't observe any daylight saving time.
|
|
||||||
// */
|
|
||||||
// public int getMaxTransitionYear() {
|
|
||||||
// if (transitions == null) {
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
// long val = transitions[transitions.length - 1];
|
|
||||||
// int offset = this.offsets[(int)(val & OFFSET_MASK)] + rawOffsetDiff;
|
|
||||||
// val = (val >> TRANSITION_NSHIFT) + offset;
|
|
||||||
// CalendarDate lastDate = Gregorian.getCalendarDate(val);
|
|
||||||
// return lastDate.getYear();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of this time zone.
|
* Returns a string representation of this time zone.
|
||||||
|
@ -669,10 +654,9 @@ public class ZoneInfo extends TimeZone {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof ZoneInfo)) {
|
if (!(obj instanceof ZoneInfo that)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ZoneInfo that = (ZoneInfo) obj;
|
|
||||||
return (getID().equals(that.getID())
|
return (getID().equals(that.getID())
|
||||||
&& (getLastRawOffset() == that.getLastRawOffset())
|
&& (getLastRawOffset() == that.getLastRawOffset())
|
||||||
&& (checksum == that.checksum));
|
&& (checksum == that.checksum));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -297,9 +297,9 @@ public final class ZoneInfoFile {
|
||||||
* Loads the rules from a DateInputStream
|
* Loads the rules from a DateInputStream
|
||||||
*
|
*
|
||||||
* @param dis the DateInputStream to load, not null
|
* @param dis the DateInputStream to load, not null
|
||||||
* @throws Exception if an error occurs
|
* @throws IOException if an error occurs
|
||||||
*/
|
*/
|
||||||
private static void load(DataInputStream dis) throws ClassNotFoundException, IOException {
|
private static void load(DataInputStream dis) throws IOException {
|
||||||
if (dis.readByte() != 1) {
|
if (dis.readByte() != 1) {
|
||||||
throw new StreamCorruptedException("File format not recognised");
|
throw new StreamCorruptedException("File format not recognised");
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,8 @@ public final class ZoneInfoFile {
|
||||||
//Current time. Used to determine future GMToffset transitions
|
//Current time. Used to determine future GMToffset transitions
|
||||||
private static final long CURRT = System.currentTimeMillis()/1000;
|
private static final long CURRT = System.currentTimeMillis()/1000;
|
||||||
|
|
||||||
/* Get a ZoneInfo instance.
|
/**
|
||||||
|
* Get a ZoneInfo instance.
|
||||||
*
|
*
|
||||||
* @param standardTransitions the standard transitions, not null
|
* @param standardTransitions the standard transitions, not null
|
||||||
* @param standardOffsets the standard offsets, not null
|
* @param standardOffsets the standard offsets, not null
|
||||||
|
@ -711,9 +712,7 @@ public final class ZoneInfoFile {
|
||||||
for (i = 0; i < transitions.length; i++) {
|
for (i = 0; i < transitions.length; i++) {
|
||||||
long val = transitions[i];
|
long val = transitions[i];
|
||||||
int dst = (int)((val >>> DST_NSHIFT) & 0xfL);
|
int dst = (int)((val >>> DST_NSHIFT) & 0xfL);
|
||||||
int saving = (dst == 0) ? 0 : offsets[dst];
|
|
||||||
int index = (int)(val & OFFSET_MASK);
|
int index = (int)(val & OFFSET_MASK);
|
||||||
int offset = offsets[index];
|
|
||||||
long second = (val >> TRANSITION_NSHIFT);
|
long second = (val >> TRANSITION_NSHIFT);
|
||||||
// javazic uses "index of the offset in offsets",
|
// javazic uses "index of the offset in offsets",
|
||||||
// instead of the real offset value itself to
|
// instead of the real offset value itself to
|
||||||
|
@ -780,13 +779,11 @@ public final class ZoneInfoFile {
|
||||||
int marchDoy0 = (int) doyEst;
|
int marchDoy0 = (int) doyEst;
|
||||||
// convert march-based values back to january-based
|
// convert march-based values back to january-based
|
||||||
int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
|
int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
|
||||||
int month = (marchMonth0 + 2) % 12 + 1;
|
|
||||||
int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1;
|
|
||||||
yearEst += marchMonth0 / 10;
|
yearEst += marchMonth0 / 10;
|
||||||
return (int)yearEst;
|
return (int)yearEst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int toCalendarDOW[] = new int[] {
|
private static final int[] toCalendarDOW = new int[] {
|
||||||
-1,
|
-1,
|
||||||
Calendar.MONDAY,
|
Calendar.MONDAY,
|
||||||
Calendar.TUESDAY,
|
Calendar.TUESDAY,
|
||||||
|
@ -797,7 +794,7 @@ public final class ZoneInfoFile {
|
||||||
Calendar.SUNDAY
|
Calendar.SUNDAY
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int toSTZTime[] = new int[] {
|
private static final int[] toSTZTime = new int[] {
|
||||||
SimpleTimeZone.UTC_TIME,
|
SimpleTimeZone.UTC_TIME,
|
||||||
SimpleTimeZone.WALL_TIME,
|
SimpleTimeZone.WALL_TIME,
|
||||||
SimpleTimeZone.STANDARD_TIME,
|
SimpleTimeZone.STANDARD_TIME,
|
||||||
|
@ -821,8 +818,8 @@ public final class ZoneInfoFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return updated nOffsets
|
// return updated nOffsets
|
||||||
private static int addTrans(long transitions[], int nTrans,
|
private static int addTrans(long[] transitions, int nTrans,
|
||||||
int offsets[], int nOffsets,
|
int[] offsets, int nOffsets,
|
||||||
long trans, int offset, int stdOffset) {
|
long trans, int offset, int stdOffset) {
|
||||||
int offsetIndex = indexOf(offsets, 0, nOffsets, offset);
|
int offsetIndex = indexOf(offsets, 0, nOffsets, offset);
|
||||||
if (offsetIndex == nOffsets)
|
if (offsetIndex == nOffsets)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue