Interface IUIDateTime
- All Known Implementing Classes:
EUIDateTime
,MLDateTime
,UIDateTime
public interface IUIDateTime
Date time interface for common routines in UIDateTime and MLDateTime.- Author:
- Christopher Mindus
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description UIDateTimeDataType
getDataType()
Returns the date-time datatype for this component.default GDateTime
getDefaultValue()
Gets the default value of the component as a GDateTime.default GDateTime
getDefaultValue(LocaleInfo localeInfo)
Gets the default value of the component as a GDateTime.int
getFormat()
Gets the format used.GDateTime.Type
getGDateTimeType()
Returns the GDateTime datatype for this component.default java.time.LocalDate
getLocalDate()
Gets the local date part of the value.default java.time.LocalTime
getLocalTime()
Gets the local time part of the value.int
getMaximumYear()
Gets the maximum year for the mobile spinner.int
getMinimumYear()
Gets the minimum year for the mobile spinner.UIDateTimeType
getUIDateTimeType()
Returns the date-time type for this component.GDateTime
getValue()
Gets the current date-time value.default java.time.ZoneId
getZoneId()
Gets the zone of the value.boolean
hasCalendarButton()
Returns whether a button to show calendar should be present for date input (mobile only).boolean
isCalendarUsed()
Returns whether a calendar should be used for date input (mobile only).boolean
isDataTypeEnforced()
Returns if the enforcement of the datatype is set.default boolean
isDateValueRequired()
Returns if the implementation requires a date in the value component.default boolean
isDateValueSupported()
Returns if the implementation supports date.boolean
isDayMonthCombined()
Returns whether to combine day and month in a single spinner (mobile).boolean
isMillisecondsUsed()
Returns whether the time value should use milliseconds in time formats using seconds.boolean
isNullAllowed()
Returns if a null value is allowed, i.e.default boolean
isTimeValueRequired()
Returns if the implementation requires a time in the value component.default boolean
isTimeValueSupported()
Returns if the implementation supports time.boolean
isZoneUsed()
Returns whether the zone should be used for a ZonedTimeDate type.boolean
setCombineDayMonth(boolean on)
Sets whether to combine day and month in a single spinner (mobile).default boolean
setDate(java.time.LocalDate localDate)
Sets the value as a local date with the locale information of the current user session (or system default) in case value conversion is required.default boolean
setDate(java.time.LocalDate localDate, LocaleInfo localeInfo)
Sets the value as a local date.boolean
setFormat(int format)
Sets the format.boolean
setNullAllowed(boolean isNullAllowed)
Sets the null value allowed flag, i.e.default boolean
setTime(java.time.LocalTime localTime)
Sets the value as a local time with the locale information of the current user session (or system default) in case value conversion is required.default boolean
setTime(java.time.LocalTime localTime, LocaleInfo localeInfo)
Sets the value as a local time.boolean
setType(UIDateTimeType type, UIDateTimeDataType dataType, boolean doEnforceDataType)
Sets the date-time type, its datatype and the enforcement flag of the datatype.boolean
setUseCalendar(boolean on)
Sets whether a calendar should be used for date input (mobile only).boolean
setUseCalendarButton(boolean on)
Sets whether a calendar button should be shown for date input (mobile only).boolean
setUseMilliseconds(boolean on)
Sets whether the time value should use milliseconds in time formats using seconds.boolean
setUseZone(boolean on)
Sets whether the zone should be used for a ZonedTimeDate type.default boolean
setValue(GDateTime value)
Sets the date-time value with the locale information of the current user session (or system default) in case value conversion is required.boolean
setValue(GDateTime value, LocaleInfo localeInfo)
Sets the date-time value.boolean
setValueToNull()
Sets the value to null.boolean
setYearRange(int min, int max)
Sets the minimum and maximum year for the mobile spinner.default boolean
setZoneId(java.time.ZoneId zone)
Sets the zone value.
Method Detail
getUIDateTimeType
UIDateTimeType getUIDateTimeType()
Returns the date-time type for this component.- Returns:
- Enum value as Time, Date, DateTime or ZoneId.
getDataType
UIDateTimeDataType getDataType()
Returns the date-time datatype for this component.- Returns:
- Enum value as Time, Date, DateTime or ZoneId.
getGDateTimeType
GDateTime.Type getGDateTimeType()
Returns the GDateTime datatype for this component.- Returns:
- Enum value as LocalTime, OffsetTime, LocalDate, LocalDateTime, OffsetDateTime or ZonedDateTime.
isDataTypeEnforced
boolean isDataTypeEnforced()
Returns if the enforcement of the datatype is set.- Returns:
- true if the datatype when setting the value MUST be exactly the same datatype, or false (default) to allow conversion to the internal configured datatype. In the Designer, this value is called "Allow data conversion", and is default true.
setType
boolean setType(UIDateTimeType type, UIDateTimeDataType dataType, boolean doEnforceDataType)
Sets the date-time type, its datatype and the enforcement flag of the datatype.Note 1: This method DOES NOT change the value, so the value may end up in the wrong datatype, and you should ensure that this does not occur.
Note 2: The
doEnforceDataType
is always true for ZoneId type.- Parameters:
type
- The type.dataType
- The datatype.- Returns:
- true if a change of type, datatype or enforcement occurred, false for no change.
- Throws:
java.lang.IllegalArgumentException
- If the type does not support the dataType.
isNullAllowed
boolean isNullAllowed()
Returns if a null value is allowed, i.e. no date/time value is set and the UI component is blank.- Returns:
- true if null is allowed, or false (default) if not allowed.
setNullAllowed
boolean setNullAllowed(boolean isNullAllowed)
Sets the null value allowed flag, i.e. allows no date/time value to be set and the UI component is blank.Setting this parameter
isNullAllowed
to false when the value already isnull
will not affect the value.- Parameters:
isNullAllowed
- Flag for null allowed.- Returns:
- true if the setting changed, false for no change.
setValueToNull
boolean setValueToNull()
Sets the value to null.- Returns:
- true for value changed, false for no change.
- Throws:
java.lang.IllegalStateException
- If the flag
isisNullAllowed()
false
.
setValue
default boolean setValue(GDateTime value)
Sets the date-time value with the locale information of the current user session (or system default) in case value conversion is required.- Parameters:
value
- The value to set, null may be allowed depending on the flag returned by
.isNullAllowed()
- Returns:
- true for value changed, false for no change to the value.
- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching.java.lang.IllegalStateException
- If the date/time conversion cannot possibly take place due to type mismatch.java.lang.NullPointerException
- If the value is null and allow null is not enabled.
setValue
boolean setValue(GDateTime value, LocaleInfo localeInfo)
Sets the date-time value.- Parameters:
value
- The value to set, null may be allowed depending on the flag returned by
.isNullAllowed()
localeInfo
- The locale information to use, or null to use the current user's or system default.- Returns:
- true for value changed, false for no change to the value.
- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching.java.lang.IllegalStateException
- If the date/time conversion cannot possibly take place due to type mismatch.java.lang.NullPointerException
- If the value is null and allow null is not enabled.
getValue
GDateTime getValue()
Gets the current date-time value.- Returns:
- The current value as configured with its datatype's corresponding GDateTime value, or
null
if the value is null and the flag
is set. The value may still be null if the "null-allowed" flag has been toggled recently programmatically toisNullAllowed()
false
but the value has not been assigned yet.
getDefaultValue
default GDateTime getDefaultValue()
Gets the default value of the component as a GDateTime.- Returns:
- The default value depends on the date/time type, i.e. the time as midnight as a LocalTime (00:00:00 for type
Time
), the epoch date as a LocalDate (1st of January 1970 for typeDate
), the combination of the two above for typeDateTime
, and the current Zone ID of the user's session (or system default) forZoneId
.
getDefaultValue
default GDateTime getDefaultValue(LocaleInfo localeInfo)
Gets the default value of the component as a GDateTime.- Parameters:
localeInfo
- The locale information to use when retrieving the Zone ID, null for current user's locale or system default.- Returns:
- The time as midnight as a LocalTime, i.e. 00:00:00 for type
TIME
, the epoch date as a LocalDate, i.e. 1st of January 1970 for typeDATE
and the combination of the two above for typeDATE_TIME
.
isTimeValueSupported
default boolean isTimeValueSupported()
Returns if the implementation supports time.- Returns:
- false when time is not supported, true when setting a value requires a time part.
isTimeValueRequired
default boolean isTimeValueRequired()
Returns if the implementation requires a time in the value component.- Returns:
- true when time is required in the component, and null is not allowed.
getLocalTime
default java.time.LocalTime getLocalTime()
Gets the local time part of the value.- Returns:
- Only the time part of the value, or null if the value is null.
- Throws:
java.lang.IllegalStateException
- If the value doesn't contain a time part, i.e. it's the wrong datatype.
setTime
default boolean setTime(java.time.LocalTime localTime)
Sets the value as a local time with the locale information of the current user session (or system default) in case value conversion is required.If the component is configured for the
UIDateTimeType.DateTime
, this will change only the time part of the value and keep offset, zone and/or date parts. To set the entire value, use
orsetValue(GDateTime)
.setValue(GDateTime, LocaleInfo)
- Parameters:
localTime
- The local time to set, null is not allowed.- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching, or in case the datatype isUIDateTimeType.Date
.java.lang.NullPointerException
- IflocalTime
is null or in case the CURRENT value is null and the datatype isUIDateTimeType.DateTime
.
setTime
default boolean setTime(java.time.LocalTime localTime, LocaleInfo localeInfo)
Sets the value as a local time.If the component is configured for the
UIDateTimeType.DateTime
, this will change only the time part of the value and keep offset, zone and/or date parts. To set the entire value, use
orsetValue(GDateTime)
.setValue(GDateTime, LocaleInfo)
- Parameters:
localTime
- The local time to set, null is not allowed.localeInfo
- The locale information to use, or null to use the current user's or system default.- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching, or in case the datatype isUIDateTimeType.Date
orUIDateTimeType.ZoneId
.java.lang.NullPointerException
- IflocalTime
is null or in case the CURRENT value is null and the datatype isUIDateTimeType.DateTime
.
isDateValueSupported
default boolean isDateValueSupported()
Returns if the implementation supports date.- Returns:
- false when date is not supported, true when setting a value requires a date part.
isDateValueRequired
default boolean isDateValueRequired()
Returns if the implementation requires a date in the value component.- Returns:
- true when date is required in the component, and null is not allowed.
getLocalDate
default java.time.LocalDate getLocalDate()
Gets the local date part of the value.- Returns:
- Only the date part of the value, or null if the value is null.
- Throws:
java.lang.IllegalStateException
- If the value doesn't contain a date part, i.e. it's the wrong datatype.
setDate
default boolean setDate(java.time.LocalDate localDate)
Sets the value as a local date with the locale information of the current user session (or system default) in case value conversion is required.If the component is configured for the
UIDateTimeType.DateTime
, this will change only the date part of the value and keep offset, zone and/or date parts. To set the entire value, use
orsetValue(GDateTime)
.setValue(GDateTime, LocaleInfo)
- Parameters:
localDate
- The local date to set, null is not allowed.- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching, or in case the datatype isUIDateTimeType.Time
.java.lang.NullPointerException
- IflocalDate
is null or in case the CURRENT value is null and the datatype isUIDateTimeType.DateTime
.
setDate
default boolean setDate(java.time.LocalDate localDate, LocaleInfo localeInfo)
Sets the value as a local date.If the component is configured for the
UIDateTimeType.DateTime
, this will change only the date part of the value and keep offset, zone and/or date parts. To set the entire value, use
orsetValue(GDateTime)
.setValue(GDateTime, LocaleInfo)
- Parameters:
localDate
- The local date to set, null is not allowed.localeInfo
- The locale information to use, or null to use the current user's or system default.- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching, or in case the datatype isUIDateTimeType.Time
orUIDateTimeType.ZoneId
.java.lang.NullPointerException
- IflocalDate
is null or in case the CURRENT value is null and the datatype isUIDateTimeType.DateTime
.
getZoneId
default java.time.ZoneId getZoneId()
Gets the zone of the value.- Returns:
- Only the zone part of the value, or null if the value is null or doesn't have a zone. It is non-null only when the value is non-null and datatype is one of OffsetTime, OffsetDateTime, ZonedDateTime or ZoneId.
setZoneId
default boolean setZoneId(java.time.ZoneId zone)
Sets the zone value.If the component is configured for the
UIDateTimeType.DateTime
, this will change only the zone part of the value.- Parameters:
zone
- The local date to set, null is not allowed.- Throws:
java.lang.IllegalArgumentException
- If the date/time type is enforced and not matching, or in case the datatype isUIDateTimeType.ZoneId
.java.lang.NullPointerException
- Ifzone
is null or in case the CURRENT value is null and the datatype isUIDateTimeType.DateTime
.
getFormat
int getFormat()
Gets the format used.- Returns:
- The format as 0=short, 1=normal, 2=long or 3=full (default).
setFormat
boolean setFormat(int format)
Sets the format.- Parameters:
format
- The format as 0=short, 1=normal, 2=long or 3=full (default).- Returns:
- true for changes, false for no change.
- Throws:
java.lang.IllegalArgumentException
- If the format is not 0-3.
getMinimumYear
int getMinimumYear()
Gets the minimum year for the mobile spinner.- Returns:
- The minimum year, or -1 if undefined.
getMaximumYear
int getMaximumYear()
Gets the maximum year for the mobile spinner.- Returns:
- The minimum year, or -1 if undefined.
setYearRange
boolean setYearRange(int min, int max)
Sets the minimum and maximum year for the mobile spinner.- Parameters:
min
- The minimum year, or -1 for no minimum, i.e. current year minus 20.max
- The maximum year, or -1 for no maximum, i.e. current year plus 20.- Returns:
- true for changed, false for no change.
- Throws:
java.lang.IllegalArgumentException
- If the min is larger than max or if either min or max is not in the range of 0-10000.
isZoneUsed
boolean isZoneUsed()
Returns whether the zone should be used for a ZonedTimeDate type.- Returns:
- true to use the zone or false (default) not to use the zone.
setUseZone
boolean setUseZone(boolean on)
Sets whether the zone should be used for a ZonedTimeDate type.- Parameters:
on
- The flag.- Returns:
- true for changes, false for no change.
isCalendarUsed
boolean isCalendarUsed()
Returns whether a calendar should be used for date input (mobile only).- Returns:
- true to use the calendar or false (default) to use spinners.
setUseCalendar
boolean setUseCalendar(boolean on)
Sets whether a calendar should be used for date input (mobile only).- Parameters:
on
- The flag.- Returns:
- true for changes, false for no change.
hasCalendarButton
boolean hasCalendarButton()
Returns whether a button to show calendar should be present for date input (mobile only).- Returns:
- true to use the calendar or false (default) to use spinners.
setUseCalendarButton
boolean setUseCalendarButton(boolean on)
Sets whether a calendar button should be shown for date input (mobile only).- Parameters:
on
- The flag.- Returns:
- true for changes, false for no change.
isMillisecondsUsed
boolean isMillisecondsUsed()
Returns whether the time value should use milliseconds in time formats using seconds.- Returns:
- true to use the zone or false (default) not to use the zone.
setUseMilliseconds
boolean setUseMilliseconds(boolean on)
Sets whether the time value should use milliseconds in time formats using seconds.- Parameters:
on
- The flag.- Returns:
- true for changes, false for no change.
isDayMonthCombined
boolean isDayMonthCombined()
Returns whether to combine day and month in a single spinner (mobile).- Returns:
- The flag, default false.
setCombineDayMonth
boolean setCombineDayMonth(boolean on)
Sets whether to combine day and month in a single spinner (mobile).- Parameters:
on
- The flag.- Returns:
- true for changes, false for no change.