use of sun.util.calendar.BaseCalendar in project Bytecoder by mirkosertic.
the class Date method toGMTString.
/**
* Creates a string representation of this {@code Date} object of
* the form:
* <blockquote><pre>
* d mon yyyy hh:mm:ss GMT</pre></blockquote>
* where:<ul>
* <li><i>d</i> is the day of the month ({@code 1} through {@code 31}),
* as one or two decimal digits.
* <li><i>mon</i> is the month ({@code Jan, Feb, Mar, Apr, May, Jun, Jul,
* Aug, Sep, Oct, Nov, Dec}).
* <li><i>yyyy</i> is the year, as four decimal digits.
* <li><i>hh</i> is the hour of the day ({@code 00} through {@code 23}),
* as two decimal digits.
* <li><i>mm</i> is the minute within the hour ({@code 00} through
* {@code 59}), as two decimal digits.
* <li><i>ss</i> is the second within the minute ({@code 00} through
* {@code 61}), as two decimal digits.
* <li><i>GMT</i> is exactly the ASCII letters "{@code GMT}" to indicate
* Greenwich Mean Time.
* </ul><p>
* The result does not depend on the local time zone.
*
* @return a string representation of this date, using the Internet GMT
* conventions.
* @see java.text.DateFormat
* @see java.util.Date#toString()
* @see java.util.Date#toLocaleString()
* @deprecated As of JDK version 1.1,
* replaced by {@code DateFormat.format(Date date)}, using a
* GMT {@code TimeZone}.
*/
@Deprecated
public String toGMTString() {
// d MMM yyyy HH:mm:ss 'GMT'
long t = getTime();
BaseCalendar cal = getCalendarSystem(t);
BaseCalendar.Date date = (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone) null);
StringBuilder sb = new StringBuilder(32);
// d
CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' ');
// MMM
convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' ');
// yyyy
sb.append(date.getYear()).append(' ');
// HH
CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':');
// mm
CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':');
// ss
CalendarUtils.sprintf0d(sb, date.getSeconds(), 2);
// ' GMT'
sb.append(" GMT");
return sb.toString();
}
use of sun.util.calendar.BaseCalendar in project Bytecoder by mirkosertic.
the class Date method normalize.
private final BaseCalendar.Date normalize() {
if (cdate == null) {
BaseCalendar cal = getCalendarSystem(fastTime);
cdate = (BaseCalendar.Date) cal.getCalendarDate(fastTime, TimeZone.getDefaultRef());
return cdate;
}
// required for the compatible behavior.
if (!cdate.isNormalized()) {
cdate = normalize(cdate);
}
// If the default TimeZone has changed, then recalculate the
// fields with the new TimeZone.
TimeZone tz = TimeZone.getDefaultRef();
if (tz != cdate.getZone()) {
cdate.setZone(tz);
CalendarSystem cal = getCalendarSystem(cdate);
cal.getCalendarDate(fastTime, cdate);
}
return cdate;
}
use of sun.util.calendar.BaseCalendar in project Bytecoder by mirkosertic.
the class Date method UTC.
/**
* 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;
}
use of sun.util.calendar.BaseCalendar in project Bytecoder by mirkosertic.
the class Date method getCalendarDate.
private final BaseCalendar.Date getCalendarDate() {
if (cdate == null) {
BaseCalendar cal = getCalendarSystem(fastTime);
cdate = (BaseCalendar.Date) cal.getCalendarDate(fastTime, TimeZone.getDefaultRef());
}
return cdate;
}
use of sun.util.calendar.BaseCalendar in project Bytecoder by mirkosertic.
the class GregorianCalendar method setGregorianChange.
private void setGregorianChange(long cutoverTime) {
gregorianCutover = cutoverTime;
gregorianCutoverDate = CalendarUtils.floorDivide(cutoverTime, ONE_DAY) + EPOCH_OFFSET;
// 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();
}
}
Aggregations