Package ch.ivyteam.ivy.scripting.objects
Class DateTime
java.lang.Object
ch.ivyteam.ivy.scripting.objects.DateTime
- All Implemented Interfaces:
IIvyDataObject
,Serializable
,Cloneable
,Comparable<DateTime>
A Timestamp object.
- See Also:
- API:
- This is a public API.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDateTime()
Creates a new DateTime object representing the actual day.DateTime
(int _year, int _month, int _day, int _hours, int _minutes, int _seconds) Creates a new date object.Creates a new DateTime object from a date and a day-time.Parses a DateTime literal and creates a new corresponding Date object.Creates a new date object. -
Method Summary
Modifier and TypeMethodDescriptionAdds a duration to this date.clone()
Creates a clone of this object.int
Compares two DataTime objects.boolean
Test two objects for euality.format()
Formats thisDateTime
with the default format.
The default format is defined in the configuration underFormats > DateTime > default
.Formats thisDateTime
with the given format config.Formats thisDateTime
with the given format configurations for the date and time part.getDate()
int
getDay()
Returns the day of this DateTime object.int
Returns the day of the week for this DateTime object.Calculates the duration from the current dateTime to actual dateTime instance.int
getHours()
Returns the hours for this DateTime object.int
Returns the minutes for this DateTime object.int
getMonth()
Returns the month of this DateTime object.int
Returns the seconds for this DateTime object.getTime()
int
getYear()
Returns the year of this DateTime object.int
hashCode()
A hashcode; the number of seconds after 1970-01-01.Returns a normalized Duration representing the difference between this DateTime and the argument.Subtracts a duration to this date.Returns a java.util.Calendar object corresponding to this DateTime object.Returns a java.util.Date object corresponding to this Date object.long
toNumber()
Converts this date to a number; this is the number of second of this date after 1970-01-01 00:00:00.toString()
Returns the date as String in the ISO-8601 format (yyyy-mm-dd hh:mm:ss).toTime()
-
Field Details
-
UNINITIALIZED_DATE_TIME
An uninitialized date object- API:
- This public API is available in Java.
-
INVALID
An invalid datetime object. Used by the widget validation- API:
- This public API is available in Java.
-
-
Constructor Details
-
DateTime
public DateTime()Creates a new DateTime object representing the actual day.- API:
- This public API is available in Java.
-
DateTime
public DateTime(int _year, int _month, int _day, int _hours, int _minutes, int _seconds) Creates a new date object.- Parameters:
_year
- The year of the DateTime object._month
- The month of the DateTime object. 1=January, 2=February .. 11=November, 12=December_day
- The day of the DateTime object. 1..28, 29, 30, 31 depending on month_hours
- The hours of the DateTime object._minutes
- The minutes of the DateTime object._seconds
- The seconds of the DateTime object.- API:
- This public API is available in Java.
-
DateTime
Creates a new DateTime object from a date and a day-time.- Parameters:
date
-time
-- API:
- This public API is available in Java.
-
DateTime
Parses a DateTime literal and creates a new corresponding Date object.If the format of the argument is not correct, an
IllegalArgumentException
will be thrown.- Parameters:
literal
- A date literal in the format- yyyy-mm-dd hh:mm:ss or
- yyyy-mm-dd hh:mm or
- dd.mm.yyyy hh:mm:ss or
- dd.mm.yyyy hh:mm.
- Throws:
IllegalArgumentException
- if the argument has an illegal format.- API:
- This public API is available in Java.
-
DateTime
Creates a new date object.- Parameters:
_date
- a java date object- API:
- This public API is available in Java.
-
-
Method Details
-
getDate
-
getTime
-
getYear
public int getYear()Returns the year of this DateTime object.- Returns:
- The year of this DateTime object.
- API:
- This public API is available in Java.
-
getMonth
public int getMonth()Returns the month of this DateTime object.- Returns:
- The month of this DateTime object. 1=January, 2=February .. 11=November, 12=December
- API:
- This public API is available in Java.
-
getDay
public int getDay()Returns the day of this DateTime object.- Returns:
- The day of this DateTime object. 1..28, 29, 30, 31 depending on month
- API:
- This public API is available in Java.
-
getDayOfWeek
public int getDayOfWeek()Returns the day of the week for this DateTime object.- Returns:
- The day of the week for this DateTime object. 1=Sunday, 2=Monday, .. 6=Friday, 7=Saturday
- API:
- This public API is available in Java.
-
getHours
public int getHours()Returns the hours for this DateTime object.- Returns:
- The hours for this DateTime object.
- API:
- This public API is available in Java.
-
getMinutes
public int getMinutes()Returns the minutes for this DateTime object.- Returns:
- The minutes for this DateTime object.
- API:
- This public API is available in Java.
-
getSeconds
public int getSeconds()Returns the seconds for this DateTime object.- Returns:
- The seconds for this DateTime object.
- API:
- This public API is available in Java.
-
add
Adds a duration to this date.- Parameters:
duration
- A duration.- Returns:
- A new date object translated by the duration.
- API:
- This public API is available in Java.
-
minus
Subtracts a duration to this date.- Parameters:
duration
- A duration.- Returns:
- A new date objact translated by the duration.
- API:
- This public API is available in Java.
-
minus
Returns a normalized Duration representing the difference between this DateTime and the argument. The result Duration has no year or month part.- Parameters:
dateTime
-- Returns:
- The difference between durations.
- API:
- This public API is available in Java.
-
getDurationFromNow
Calculates the duration from the current dateTime to actual dateTime instance.- Returns:
- Duration from the current dateTime to actual dateTime instance.
- API:
- This public API is available in Java.
-
toNumber
public long toNumber()Converts this date to a number; this is the number of second of this date after 1970-01-01 00:00:00.- Returns:
- Number of seconds after 1970-01-01 00:00:00.
- API:
- This public API is available in Java.
-
compareTo
Compares two DataTime objects.- Parameters:
otherDateTime
- Some date.- Returns:
- -1 if the receiver is before the argument, 0 if the receiver is equal to the argument 1 if the receiver is after the argument.
- API:
- This public API is available in Java.
-
toString
Returns the date as String in the ISO-8601 format (yyyy-mm-dd hh:mm:ss).- Returns:
- The date as String in the ISO-8601 format (yyyy-mm-dd).
- API:
- This public API is available in Java.
-
toIvyDate
-
toJavaDate
Returns a java.util.Date object corresponding to this Date object.Note: under ivy script environment a
Date
object is automatically converted toDateTime
.- Returns:
- A java.util.Date object corresponding to this Date object.
- API:
- This public API is available in Java.
-
toCalendar
Returns a java.util.Calendar object corresponding to this DateTime object.- Returns:
- A java.util.Calendar object corresponding to this DateTime object.
- API:
- This public API is available in Java.
-
toTime
-
format
Formats thisDateTime
with the default format.
The default format is defined in the configuration underFormats > DateTime > default
.- Returns:
- formatted String
- API:
- This public API is available in Java.
-
format
Formats thisDateTime
with the given format config.- Parameters:
formatName
- Name of a configuration underFormats > DateTime
.
E.g. "default", "medium", "short" etc.- Returns:
- formatted String
- API:
- This public API is available in Java.
-
format
Formats thisDateTime
with the given format configurations for the date and time part.- Parameters:
dateFormatName
- Name of a configuration underFormats > Date
.
E.g. "default", "medium", "short" etc.timeFormatName
- Name of a configuration underFormats > Time
.
E.g. "default", "medium", "short" etc.- Returns:
- formatted String
- API:
- This public API is available in Java.
-
equals
Test two objects for euality.- Parameters:
anotherDate
- Some object.- Returns:
- true if the receiver is equal to the argument.
- API:
- This public API is available in Java.
-
hashCode
public int hashCode()A hashcode; the number of seconds after 1970-01-01.- Returns:
- A hashcode.
- API:
- This public API is available in Java.
-
clone
Creates a clone of this object.- Specified by:
clone
in interfaceIIvyDataObject
- Returns:
- A shallow clone.
- API:
- This public API is available in Java.
-