Package org.apache.derby.client.am
Class DateTimeValue
java.lang.Object
org.apache.derby.client.am.DateTimeValue
This class represents a date or time value as it is represented in the
database. In contrast to
java.sql.Date
, java.sql.Time
and
java.sql.Timestamp
, which are based on java.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 a java.util.Calendar
object.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDateTimeValue
(Date date) Create an instance from ajava.sql.Date
using the default calendar.(package private)
DateTimeValue
(Date date, Calendar cal) Create an instance from ajava.sql.Timestamp
using the specifiedjava.util.Calendar
.DateTimeValue
(Time time) Create an instance from ajava.sql.Time
using the default calendar.(package private)
DateTimeValue
(Time time, Calendar cal) Create an instance from ajava.sql.Time
using the specifiedjava.util.Calendar
.Create an instance from ajava.sql.Timestamp
using the default calendar.(package private)
DateTimeValue
(Timestamp ts, Calendar cal) Create an instance from ajava.sql.Timestamp
using the specifiedjava.util.Calendar
.private
DateTimeValue
(Calendar cal, int nanoFraction) Construct aDateTimeValue
from ajava.util.Calendar
. -
Method Summary
Modifier and TypeMethodDescriptionint
Get day of month component.int
getHours()
Get hour of day component (24 hour clock).int
Get minute component.int
getMonth()
Get the month component.int
getNanos()
Get nanosecond component.int
Get second component.int
getYear()
Get the year component.private static Calendar
initCalendar
(Calendar cal, Date date) Set the time of a calendar.
-
Field Details
-
year
private final int year -
month
private final int month -
day
private final int day -
hours
private final int hours -
minutes
private final int minutes -
seconds
private final int seconds -
nanos
private final int nanos
-
-
Constructor Details
-
DateTimeValue
Construct aDateTimeValue
from 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
Create an instance from ajava.sql.Timestamp
using the specifiedjava.util.Calendar
. -
DateTimeValue
Create an instance from ajava.sql.Time
using the specifiedjava.util.Calendar
. -
DateTimeValue
Create an instance from ajava.sql.Timestamp
using the specifiedjava.util.Calendar
. -
DateTimeValue
Create an instance from ajava.sql.Date
using the default calendar. -
DateTimeValue
Create an instance from ajava.sql.Time
using the default calendar. -
DateTimeValue
Create an instance from ajava.sql.Timestamp
using the default calendar.
-
-
Method Details
-
initCalendar
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.
-