public class DateTime extends DateTimeBase
The format is defined by W3C XML Schema Recommendation and ISO8601 i.e (-)CCYY-MM-DD'T'HH:MM:SS(.SSSSS)(Z|(+|-)hh:mm)
EQUALS, GREATER_THAN, INDETERMINATE, LESS_THAN, MAX_TIME_ZONE_COMPARISON_OFFSET, WRONGLY_PLACED
Constructor and Description |
---|
DateTime()
Default constructor.
|
DateTime(Date dateRef)
Creates a new XML Schema DateTime instance from a java.util.Date.
|
DateTime(long dateAsLong)
Creates a new XML Schema DateTime instance from a long that represents a
Date.
|
DateTime(short[] values)
Constructs a XML Schema DateTime instance given all the values of the
different date and time (but not time zone) fields.
|
DateTime(String date)
Constructs a DateTime from a String.
|
Modifier and Type | Method and Description |
---|---|
short[] |
getValues()
Returns an array of shorts with all the fields that describe this
DateTime type.
|
static DateTime |
parse(String str)
Parses a String into a new DateTime instance.
|
static DateTime |
parseDateTime(String str)
Parses a String into a new DateTime instance.
|
void |
setValues(short[] values)
Sets all the fields to the values provided in an Array.
|
Date |
toDate()
Converts this DateTime into a local java.util.Date.
|
long |
toLong()
Converts this DateTime into a long value representing a java.util.Date.
|
String |
toString()
Converts this DateTime to a string.
|
addDuration, appendDateString, appendTimeString, appendTimeZoneString, clone, compareTo, equal, equals, getCentury, getDay, getHour, getMilli, getMinute, getMonth, getSeconds, getYear, getZoneHour, getZoneMinute, hasCentury, hasDay, hashCode, hasHour, hasIsNegative, hasMilli, hasMinute, hasMonth, hasSeconds, hasYear, isLeap, isNegative, isUTC, isZoneNegative, normalize, parseDay, parseMonth, parseTime, parseTimeZone, parseYear, setCentury, setDateFormatTimeZone, setDateFormatTimeZone, setDay, setHour, setMilliSecond, setMinute, setMonth, setNegative, setSecond, setSecond, setUTC, setYear, setZone, setZoneHour, setZoneMinute, setZoneNegative, toCalendar
public DateTime()
public DateTime(short[] values)
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call DateTimeBase.setZone(short, short)
.
values
- an array of shorts that represent the different fields of
Time.setValues(short[])
public DateTime(long dateAsLong)
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call DateTimeBase.setZone(short, short)
.
dateAsLong
- java.util.Date represented as a long.public DateTime(Date dateRef)
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call DateTimeBase.setZone(short, short)
.
dateRef
- a java.util.Date to convert.public DateTime(String date) throws ParseException
date
- the string representing the dateParseException
- if we are passed an illegal valuepublic void setValues(short[] values)
setZone
. A time zone
previously set will not be cleared.setValues
in class DateTimeBase
values
- An array of shorts containing the values for the DateTimepublic short[] getValues()
getValues
in class DateTimeBase
public Date toDate()
toDate
in class DateTimeBase
public long toLong()
public String toString()
public static DateTime parse(String str) throws ParseException
str
- the string to parseParseException
- If the string to parse does not follow the right formatpublic static DateTime parseDateTime(String str) throws ParseException
str
- the string to parseParseException
- If the string to parse does not follow the right formatCopyright © 2014. All rights reserved.