Class PickerUtilities
- java.lang.Object
-
- com.github.lgooddatepicker.optionalusertools.PickerUtilities
-
public class PickerUtilities extends java.lang.Object
DateUtilities, This is a set of date or date picker related utilities that may be useful to developers using this project.
-
-
Constructor Summary
Constructors Constructor Description PickerUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.time.format.DateTimeFormatter
createFormatterFromPatternString(java.lang.String formatPattern, java.util.Locale locale)
createFormatterFromPatternString, This creates a DateTimeFormatter from the supplied pattern string and supplied locale.static boolean
isLocalTimeInRange(java.time.LocalTime value, java.time.LocalTime optionalMinimum, java.time.LocalTime optionalMaximum, boolean inclusiveOfEndpoints)
isLocalTimeInRange, This returns true if the specified value is inside of the specified range.static boolean
isSameLocalDate(java.time.LocalDate first, java.time.LocalDate second)
isSameLocalDate, This compares two date variables to see if their values are equal.static boolean
isSameLocalTime(java.time.LocalTime first, java.time.LocalTime second)
static java.lang.String
localDateTimeToString(java.time.LocalDateTime value)
localDateTimeToString, This will return the supplied LocalDateTime as a string.static java.lang.String
localDateTimeToString(java.time.LocalDateTime value, java.lang.String emptyTimeString)
localDateTimeToString, This will return the supplied LocalDateTime as a string.static java.lang.String
localDateToString(java.time.LocalDate date)
localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd).static java.lang.String
localDateToString(java.time.LocalDate date, java.lang.String emptyDateString)
localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd).static java.lang.String
localTimeToString(java.time.LocalTime time)
localTimeToString, This will return the supplied time as a string.static java.lang.String
localTimeToString(java.time.LocalTime time, java.lang.String emptyTimeString)
localTimeToString, This will return the supplied time as a string.
-
-
-
Method Detail
-
createFormatterFromPatternString
public static java.time.format.DateTimeFormatter createFormatterFromPatternString(java.lang.String formatPattern, java.util.Locale locale)
createFormatterFromPatternString, This creates a DateTimeFormatter from the supplied pattern string and supplied locale. The pattern will be created to be "lenient" and "case insensitive", so it can be used for display or for user-friendly parsing. Information about creating a pattern string can be found in the DateTimeFormatter class Javadocs. @see The DateTimeFormatter Javadocs Note: It is important to use the letter "u" (astronomical year) instead of "y" (year of era) when creating pattern strings for BCE dates. This is because the DatePicker uses ISO 8601, which specifies "Astronomical year numbering". (Additional details: The astronomical year "-1" and "1 BC" are not the same thing. Astronomical years are zero-based, and BC dates are one-based. Astronomical year "0", is the same year as "1 BC", and astronomical year "-1" is the same year as "2 BC", and so forth.)
-
isLocalTimeInRange
public static boolean isLocalTimeInRange(java.time.LocalTime value, java.time.LocalTime optionalMinimum, java.time.LocalTime optionalMaximum, boolean inclusiveOfEndpoints)
isLocalTimeInRange, This returns true if the specified value is inside of the specified range. This returns false if the specified value is outside of the specified range. If the specified value is null, then this will return false. If optionalMinimum is null, then it will be set to LocalTime.MIN. If optionalMaximum is null, then it will be set to LocalTime.MAX. If inclusiveOfEndpoints is true, then values that equal the minimum or maximum will return true. Otherwise, values that equal the minimum or maximum will return false.
-
isSameLocalDate
public static boolean isSameLocalDate(java.time.LocalDate first, java.time.LocalDate second)
isSameLocalDate, This compares two date variables to see if their values are equal. Returns true if the values are equal, otherwise returns false. More specifically: This returns true if both values are null (an empty date). Or, this returns true if both of the supplied dates contain a date and represent the same date. Otherwise this returns false.
-
isSameLocalTime
public static boolean isSameLocalTime(java.time.LocalTime first, java.time.LocalTime second)
-
localDateTimeToString
public static java.lang.String localDateTimeToString(java.time.LocalDateTime value, java.lang.String emptyTimeString)
localDateTimeToString, This will return the supplied LocalDateTime as a string. If the value is null, this will return the value of emptyTimeString. Time values will be output in the same format as LocalDateTime.toString(). Javadocs from LocalDateTime.toString(): Outputs this date-time as aString
, such as2007-12-03T10:15:30
.The output will be one of the following ISO-8601 formats:
uuuu-MM-dd'T'HH:mm
uuuu-MM-dd'T'HH:mm:ss
uuuu-MM-dd'T'HH:mm:ss.SSS
uuuu-MM-dd'T'HH:mm:ss.SSSSSS
uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS
-
localDateTimeToString
public static java.lang.String localDateTimeToString(java.time.LocalDateTime value)
localDateTimeToString, This will return the supplied LocalDateTime as a string. If the value is null, this will return an empty string (""). Time values will be output in the same format as LocalDateTime.toString(). Javadocs from LocalDateTime.toString(): Outputs this date-time as aString
, such as2007-12-03T10:15:30
.The output will be one of the following ISO-8601 formats:
uuuu-MM-dd'T'HH:mm
uuuu-MM-dd'T'HH:mm:ss
uuuu-MM-dd'T'HH:mm:ss.SSS
uuuu-MM-dd'T'HH:mm:ss.SSSSSS
uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS
-
localDateToString
public static java.lang.String localDateToString(java.time.LocalDate date)
localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd). For any CE years that are between 0 and 9999 inclusive, the output will have a fixed length of 10 characters. Years before or after that range will output longer strings. If the date is null, this will return an empty string ("").
-
localDateToString
public static java.lang.String localDateToString(java.time.LocalDate date, java.lang.String emptyDateString)
localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd). For any CE years that are between 0 and 9999 inclusive, the output will have a fixed length of 10 characters. Years before or after that range will output longer strings. If the date is null, this will return the value of emptyDateString.
-
localTimeToString
public static java.lang.String localTimeToString(java.time.LocalTime time)
localTimeToString, This will return the supplied time as a string. If the time is null, this will return an empty string (""). Time values will be output in one of the following ISO-8601 formats: "HH:mm", "HH:mm:ss", "HH:mm:ss.SSS", "HH:mm:ss.SSSSSS", "HH:mm:ss.SSSSSSSSS". The format used will be the shortest that outputs the full value of the time where the omitted parts are implied to be zero.
-
localTimeToString
public static java.lang.String localTimeToString(java.time.LocalTime time, java.lang.String emptyTimeString)
localTimeToString, This will return the supplied time as a string. If the time is null, this will return the value of emptyTimeString. Time values will be output in one of the following ISO-8601 formats: "HH:mm", "HH:mm:ss", "HH:mm:ss.SSS", "HH:mm:ss.SSSSSS", "HH:mm:ss.SSSSSSSSS". The format used will be the shortest that outputs the full value of the time where the omitted parts are implied to be zero.
-
-