Package ch.ivyteam.ivy.scripting.objects
Class Date
java.lang.Object
ch.ivyteam.ivy.scripting.objects.Date
- All Implemented Interfaces:
IIvyDataObject
,Serializable
,Cloneable
,Comparable<Date>
Ivy Date objects have a year, a month and a day, but no day-time.
- See Also:
- API:
- This is a public API.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDate()
Creates a new Date object representing the actual day.Date
(int _year, int _month, int _day) Creates a new date object.Parses a Date literal and creates a new corresponding Date object.Creates a new date object.Date
(GregorianCalendar _calendar) 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 dates.boolean
Test two objects for equality.format()
Formats thisDate
with the default format.
The default format is defined in the configuration underFormats > Date > default
.Formats thisDate
with the given format config.int
getDay()
Returns the day of the date.int
Returns the day of the week for this date.Calculates the duration from the current date to actual date instance.int
getMonth()
Returns the month of the date.int
getYear()
Returns the year of the date.int
hashCode()
A hash code.Returns a normalized Duration representing the difference between this Date and the argument.Subtracts a duration to this date.Returns a java.util.Calendar object corresponding to this Date 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).
-
Field Details
-
UNINITIALIZED_DATE
An uninitialized date object.- API:
- This public API is available in Java.
-
INVALID
An invalid date object. Used by the widget validation- API:
- This public API is available in Java.
-
-
Constructor Details
-
Date
public Date()Creates a new Date object representing the actual day.- API:
- This public API is available in Java.
-
Date
public Date(int _year, int _month, int _day) Creates a new date object.- Parameters:
_year
- The year of the date._month
- The month of the date. 1=January, 2=February, .. 11=November, 12=December_day
- The day of the date. 1..28, 29, 30, 31 depending on month- API:
- This public API is available in Java.
-
Date
Parses a Date literal and creates a new corresponding Date object. If the format of the argument is not correct, an uninitialized Object is created.- Parameters:
literal
- A date literal in the format yyyy-mm-dd or dd.mm.yyyy.- Throws:
IllegalArgumentException
- if the argument has an illegal format.- API:
- This public API is available in Java.
-
Date
Creates a new date object.- Parameters:
_calendar
- The calendar for the date.- API:
- This public API is available in Java.
-
Date
Creates a new date object.- Parameters:
_date
- a java date object- API:
- This public API is available in Java.
-
-
Method Details
-
getYear
public int getYear()Returns the year of the date.- Returns:
- The year of the date.
- API:
- This public API is available in Java.
-
getMonth
public int getMonth()Returns the month of the date.- Returns:
- The month of the date. 1=January, 2=February .. 11=November, 12=December
- API:
- This public API is available in Java.
-
getDay
public int getDay()Returns the day of the date.- Returns:
- The day of the date. 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 date.- Returns:
- The day of the week for this date. 1=Sunday, 2=Monday, .. 6=Friday, 7=Saturday
- API:
- This public API is available in Java.
-
add
Adds 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
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 Date and the argument. The result Duration has no year or month part.- Parameters:
date
-- Returns:
- a normalized Duration.
- API:
- This public API is available in Java.
-
getDurationFromNow
Calculates the duration from the current date to actual date instance.- Returns:
- Duration from the current date to actual date 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 dates.- Parameters:
otherDate
- 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).- Returns:
- The date as String in the ISO-8601 format (yyyy-mm-dd).
- API:
- This public API is available in Java.
-
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 Date object.- Returns:
- A java.util.Calendar object corresponding to this Date object.
- API:
- This public API is available in Java.
-
format
Formats thisDate
with the default format.
The default format is defined in the configuration underFormats > Date > default
.- Returns:
- formatted String
- API:
- This public API is available in Java.
-
format
Formats thisDate
with the given format config.- Parameters:
formatName
- Name of a configuration underFormats > Date
.
E.g. "default", "medium", "short" etc.- Returns:
- formatted String
- API:
- This public API is available in Java.
-
equals
Test two objects for equality.- 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 hash code.- Returns:
- A hash code.
- 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.
-