Package org.apache.derby.client.am
Class DateTimeValue
- java.lang.Object
-
- org.apache.derby.client.am.DateTimeValue
-
public class DateTimeValue extends java.lang.ObjectThis class represents a date or time value as it is represented in the database. In contrast tojava.sql.Date,java.sql.Timeandjava.sql.Timestamp, which are based onjava.util.Date, this class does not represent the time as an offset from midnight, January 1, 1970 GMT. Instead, it holds each component (year, month, day, hour, minute, second, nanosecond) as it would have been represented in a given calendar. Since it does not hold information about the time zone for the time it represents, it does not point to a well-defined point in time without being used together with ajava.util.Calendarobject.
-
-
Constructor Summary
Constructors Modifier Constructor Description DateTimeValue(java.sql.Date date)Create an instance from ajava.sql.Dateusing the default calendar.(package private)DateTimeValue(java.sql.Date date, java.util.Calendar cal)Create an instance from ajava.sql.Timestampusing the specifiedjava.util.Calendar.DateTimeValue(java.sql.Time time)Create an instance from ajava.sql.Timeusing the default calendar.(package private)DateTimeValue(java.sql.Time time, java.util.Calendar cal)Create an instance from ajava.sql.Timeusing the specifiedjava.util.Calendar.DateTimeValue(java.sql.Timestamp ts)Create an instance from ajava.sql.Timestampusing the default calendar.(package private)DateTimeValue(java.sql.Timestamp ts, java.util.Calendar cal)Create an instance from ajava.sql.Timestampusing the specifiedjava.util.Calendar.privateDateTimeValue(java.util.Calendar cal, int nanoFraction)Construct aDateTimeValuefrom ajava.util.Calendar.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetDayOfMonth()Get day of month component.intgetHours()Get hour of day component (24 hour clock).intgetMinutes()Get minute component.intgetMonth()Get the month component.intgetNanos()Get nanosecond component.intgetSeconds()Get second component.intgetYear()Get the year component.private static java.util.CalendarinitCalendar(java.util.Calendar cal, java.util.Date date)Set the time of a calendar.
-
-
-
Constructor Detail
-
DateTimeValue
private DateTimeValue(java.util.Calendar cal, int nanoFraction)Construct aDateTimeValuefrom ajava.util.Calendar.- Parameters:
cal- the calendar from which to get the values of the fieldsnanoFraction- the nano second fraction of a second (the milliseconds will be taken fromcal, so only the six least significant digits of this value are used)
-
DateTimeValue
DateTimeValue(java.sql.Date date, java.util.Calendar cal)Create an instance from ajava.sql.Timestampusing the specifiedjava.util.Calendar.
-
DateTimeValue
DateTimeValue(java.sql.Time time, java.util.Calendar cal)Create an instance from ajava.sql.Timeusing the specifiedjava.util.Calendar.
-
DateTimeValue
DateTimeValue(java.sql.Timestamp ts, java.util.Calendar cal)Create an instance from ajava.sql.Timestampusing the specifiedjava.util.Calendar.
-
DateTimeValue
public DateTimeValue(java.sql.Date date)
Create an instance from ajava.sql.Dateusing the default calendar.
-
DateTimeValue
public DateTimeValue(java.sql.Time time)
Create an instance from ajava.sql.Timeusing the default calendar.
-
DateTimeValue
public DateTimeValue(java.sql.Timestamp ts)
Create an instance from ajava.sql.Timestampusing the default calendar.
-
-
Method Detail
-
initCalendar
private static java.util.Calendar initCalendar(java.util.Calendar cal, java.util.Date date)Set the time of a calendar.- Parameters:
cal- the calendardate- an object representing the new time of the calendar- Returns:
- the calendar (same as
cal)
-
getYear
public int getYear()
Get the year component.
-
getMonth
public int getMonth()
Get the month component. First month is 0 (Calendar.JANUARY).
-
getDayOfMonth
public int getDayOfMonth()
Get day of month component. First day of the month is 1.
-
getHours
public int getHours()
Get hour of day component (24 hour clock).
-
getMinutes
public int getMinutes()
Get minute component.
-
getSeconds
public int getSeconds()
Get second component.
-
getNanos
public int getNanos()
Get nanosecond component.
-
-