com.caucho.util
Class QDate

java.lang.Object
  extended by com.caucho.util.QDate

public class QDate
extends java.lang.Object

Resin Date object


Field Summary
static int DAY
           
static int DAY_OF_MONTH
           
static int DAY_OF_WEEK
           
static int HOUR
           
static int MILLISECOND
           
static int MINUTE
           
static int MONTH
           
static int SECOND
           
static int TIME
           
static int TIME_ZONE
           
static int YEAR
           
 
Constructor Summary
QDate()
          Creates the date for GMT.
QDate(boolean isLocal)
          Creates the date form local or GMT.
QDate(long time)
          Creates the date for GMT.
QDate(long year, long month, long dayOfMonth)
          Creates the date for the local time zone.
QDate(java.util.TimeZone zone)
          Creates the date from local or GMT.
QDate(java.util.TimeZone zone, long now)
          Creates the date from local or GMT.
 
Method Summary
static QDate allocateGmtDate()
           
static QDate allocateLocalDate()
           
 java.lang.Object clone()
           
static QDate createLocal()
          Creates a local calendar.
 CharBuffer format(CharBuffer cb, java.lang.String format)
          Format the date using % escapes: %aday of week (short) %Aday of week (verbose) %bday of month (short) %Bday of month (verbose) %cJava locale date %dday of month (two-digit) %H24-hour (two-digit) %I12-hour (two-digit) %jday of year (three-digit) %mmonth (two-digit) %Mminutes %pam/pm %Sseconds %smilliseconds %xJava locale short date %XJava locale short time %Wweek in year (three-digit) %wday of week (one-digit) %yyear (two-digit) %Yyear (four-digit) %Ztime zone (name) %ztime zone (+/-0800)
 java.lang.String format(java.lang.String format)
          Formats the current date.
static java.lang.String formatGMT(long gmtTime)
          Formats a date, using the default time format.
static java.lang.String formatGMT(long gmtTime, java.lang.String format)
          Formats a date.
static java.lang.String formatISO8601(long gmtTime)
           
static CharBuffer formatLocal(CharBuffer cb, long gmtTime, java.lang.String format)
          Formats a time in the local time zone.
static java.lang.String formatLocal(long gmtTime)
          Formats a time in the local time zone, using the default format.
static java.lang.String formatLocal(long gmtTime, java.lang.String format)
          Formats a time in the local time zone.
static void freeGmtDate(QDate date)
           
static void freeLocalDate(QDate date)
           
 long get(int field)
          Gets values based on a field.
 java.util.Calendar getCalendar()
          Return the current time as a java.util.Calendar.
 int getDayOfMonth()
          Returns the day of the month, based on 1 for the first of the month.
 int getDayOfWeek()
          Returns the day of the week.
 int getDayOfYear()
          Returns the day of the year, based on 0 for January 1.
 int getDaysInMonth()
          Returns the day of the month, based on 1 for the first of the month.
static QDate getGlobalDate()
          Global date must be synchronized before you can do anything on it.
 long getGMTTime()
          Returns the time in milliseconds since the epoch.
 int getHour()
          Returns the hour.
 long getLocalTime()
          Returns the time in milliseconds since the epoch.
 java.util.TimeZone getLocalTimeZone()
          Returns the current time zone.
 long getMillisecond()
          Returns the millisecond.
 int getMinute()
          Returns the minute.
 int getMonth()
          Returns the month in the year.
 int getSecond()
          Returns the second.
 long getTimeOfDay()
          Returns the milliseconds since the beginning of the day.
 int getWeek()
          Returns the week in the year.
 int getYear()
          Returns the year.
 java.lang.String getZoneName()
          Returns the name of the timezone
 long getZoneOffset()
          Returns the time zone offset for that particular day.
 boolean isDST()
          Returns true for DST
 boolean isLeapYear()
           
 long parseDate(java.lang.String string)
           
 long parseLocalDate(java.lang.String string)
           
 java.lang.String printDate()
           
 void printDate(CharBuffer cb)
           
 void printDate(WriteStream os)
          Prints the date to a stream.
 java.lang.String printISO8601()
          Prints the time in ISO 8601
 java.lang.String printISO8601Date()
          Prints just the date component of ISO 8601
 java.lang.String printLocaleDate()
           
 void printRFC2822(CharBuffer cb)
           
 java.lang.String printShortLocaleDate()
          Returns a date in M/dd/yy format (i.e.
 java.lang.String printShortLocaleTime()
          Returns a date in H:mm:ss PM format.
 long set(int field, long value)
          Sets values based on a field.
 long setDate(long year, long month, long day)
          Sets date in the local time.
 void setDayOfMonth(int day)
          sets the day of the month based on 1 for the first of the month.
 void setGMTTime(long time)
          Sets the time in milliseconds since the epoch and calculate the internal variables.
 void setHour(int hour)
          Sets the hour, recalculating the localTimeOfEpoch.
 void setLocalTime(long time)
          Sets the time in milliseconds since the epoch and calculate the internal variables.
 void setMillisecond(long millisecond)
          Sets the millisecond, recalculating the localTimeOfEpoch.
 void setMinute(int minute)
          Sets the minute, recalculating the localTimeOfEpoch.
 void setMonth(int month)
          Sets the month in the year.
 void setSecond(int second)
          Sets the second, recalculating the localTimeOfEpoch.
 long setTime(long hour, long minute, long second, long ms)
           
 void setYear(int year)
          Sets the year, recalculating the time since epoch.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

YEAR

public static final int YEAR
See Also:
Constant Field Values

MONTH

public static final int MONTH
See Also:
Constant Field Values

DAY_OF_MONTH

public static final int DAY_OF_MONTH
See Also:
Constant Field Values

DAY

public static final int DAY
See Also:
Constant Field Values

DAY_OF_WEEK

public static final int DAY_OF_WEEK
See Also:
Constant Field Values

HOUR

public static final int HOUR
See Also:
Constant Field Values

MINUTE

public static final int MINUTE
See Also:
Constant Field Values

SECOND

public static final int SECOND
See Also:
Constant Field Values

MILLISECOND

public static final int MILLISECOND
See Also:
Constant Field Values

TIME

public static final int TIME
See Also:
Constant Field Values

TIME_ZONE

public static final int TIME_ZONE
See Also:
Constant Field Values
Constructor Detail

QDate

public QDate()
Creates the date for GMT.


QDate

public QDate(long time)
Creates the date for GMT.


QDate

public QDate(boolean isLocal)
Creates the date form local or GMT.


QDate

public QDate(java.util.TimeZone zone)
Creates the date from local or GMT.


QDate

public QDate(java.util.TimeZone zone,
             long now)
Creates the date from local or GMT.


QDate

public QDate(long year,
             long month,
             long dayOfMonth)
Creates the date for the local time zone.

See Also:
setDate(long, long, long)
Method Detail

createLocal

public static QDate createLocal()
Creates a local calendar.


allocateLocalDate

public static QDate allocateLocalDate()

freeLocalDate

public static void freeLocalDate(QDate date)

allocateGmtDate

public static QDate allocateGmtDate()

freeGmtDate

public static void freeGmtDate(QDate date)

setLocalTime

public void setLocalTime(long time)
Sets the time in milliseconds since the epoch and calculate the internal variables.


getLocalTime

public long getLocalTime()
Returns the time in milliseconds since the epoch.


getCalendar

public java.util.Calendar getCalendar()
Return the current time as a java.util.Calendar.


setGMTTime

public void setGMTTime(long time)
Sets the time in milliseconds since the epoch and calculate the internal variables.


getGMTTime

public long getGMTTime()
Returns the time in milliseconds since the epoch.


getTimeOfDay

public long getTimeOfDay()
Returns the milliseconds since the beginning of the day.


getYear

public int getYear()
Returns the year.


setYear

public void setYear(int year)
Sets the year, recalculating the time since epoch.


getMonth

public int getMonth()
Returns the month in the year.


setMonth

public void setMonth(int month)
Sets the month in the year.


getDayOfMonth

public int getDayOfMonth()
Returns the day of the month, based on 1 for the first of the month.


setDayOfMonth

public void setDayOfMonth(int day)
sets the day of the month based on 1 for the first of the month.


getDaysInMonth

public int getDaysInMonth()
Returns the day of the month, based on 1 for the first of the month.


getDayOfWeek

public int getDayOfWeek()
Returns the day of the week.


getDayOfYear

public int getDayOfYear()
Returns the day of the year, based on 0 for January 1.


getHour

public int getHour()
Returns the hour.


setHour

public void setHour(int hour)
Sets the hour, recalculating the localTimeOfEpoch.


getMinute

public int getMinute()
Returns the minute.


setMinute

public void setMinute(int minute)
Sets the minute, recalculating the localTimeOfEpoch.


getSecond

public int getSecond()
Returns the second.


setSecond

public void setSecond(int second)
Sets the second, recalculating the localTimeOfEpoch.


getMillisecond

public long getMillisecond()
Returns the millisecond.


setMillisecond

public void setMillisecond(long millisecond)
Sets the millisecond, recalculating the localTimeOfEpoch.


getZoneOffset

public long getZoneOffset()
Returns the time zone offset for that particular day.


getZoneName

public java.lang.String getZoneName()
Returns the name of the timezone


isDST

public boolean isDST()
Returns true for DST


getLocalTimeZone

public java.util.TimeZone getLocalTimeZone()
Returns the current time zone.


getWeek

public int getWeek()
Returns the week in the year.


get

public long get(int field)
Gets values based on a field.


set

public long set(int field,
                long value)
Sets values based on a field.


printDate

public java.lang.String printDate()

printDate

public void printDate(CharBuffer cb)

printDate

public void printDate(WriteStream os)
               throws java.io.IOException
Prints the date to a stream.

Throws:
java.io.IOException

printRFC2822

public void printRFC2822(CharBuffer cb)

printISO8601

public java.lang.String printISO8601()
Prints the time in ISO 8601


printISO8601Date

public java.lang.String printISO8601Date()
Prints just the date component of ISO 8601


formatGMT

public static java.lang.String formatGMT(long gmtTime,
                                         java.lang.String format)
Formats a date.

Parameters:
time - the time to format
format - the format string

formatGMT

public static java.lang.String formatGMT(long gmtTime)
Formats a date, using the default time format.

Parameters:
time - the time to format

formatLocal

public static java.lang.String formatLocal(long gmtTime,
                                           java.lang.String format)
Formats a time in the local time zone.

Parameters:
time - in milliseconds, GMT, from the epoch.
format - formatting string.

formatLocal

public static java.lang.String formatLocal(long gmtTime)
Formats a time in the local time zone, using the default format.

Parameters:
time - in milliseconds, GMT, from the epoch.

formatLocal

public static CharBuffer formatLocal(CharBuffer cb,
                                     long gmtTime,
                                     java.lang.String format)
Formats a time in the local time zone.

Parameters:
time - in milliseconds, GMT, from the epoch.
format - formatting string.

formatISO8601

public static java.lang.String formatISO8601(long gmtTime)

getGlobalDate

public static QDate getGlobalDate()
Global date must be synchronized before you can do anything on it.


format

public java.lang.String format(java.lang.String format)
Formats the current date.


format

public CharBuffer format(CharBuffer cb,
                         java.lang.String format)
Format the date using % escapes:
%aday of week (short)
%Aday of week (verbose)
%bday of month (short)
%Bday of month (verbose)
%cJava locale date
%dday of month (two-digit)
%H24-hour (two-digit)
%I12-hour (two-digit)
%jday of year (three-digit)
%mmonth (two-digit)
%Mminutes
%pam/pm
%Sseconds
%smilliseconds
%xJava locale short date
%XJava locale short time
%Wweek in year (three-digit)
%wday of week (one-digit)
%yyear (two-digit)
%Yyear (four-digit)
%Ztime zone (name)
%ztime zone (+/-0800)


printLocaleDate

public java.lang.String printLocaleDate()

printShortLocaleDate

public java.lang.String printShortLocaleDate()
Returns a date in M/dd/yy format (i.e. 11/30/69 in US locale).


printShortLocaleTime

public java.lang.String printShortLocaleTime()
Returns a date in H:mm:ss PM format.


parseLocalDate

public long parseLocalDate(java.lang.String string)
                    throws java.lang.Exception
Throws:
java.lang.Exception

parseDate

public long parseDate(java.lang.String string)
               throws java.lang.Exception
Throws:
java.lang.Exception

setDate

public long setDate(long year,
                    long month,
                    long day)
Sets date in the local time.

Parameters:
year -
month - where January = 0
day - day of month where the 1st = 1

setTime

public long setTime(long hour,
                    long minute,
                    long second,
                    long ms)

isLeapYear

public boolean isLeapYear()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object