Class PickerUtilities
java.lang.Object
com.github.lgooddatepicker.optionalusertools.PickerUtilities
DateUtilities, This is a set of date or date picker related utilities that may be useful to
developers using this project.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DateTimeFormatter
createFormatterFromPatternString
(String formatPattern, Locale locale) createFormatterFromPatternString, This creates a DateTimeFormatter from the supplied pattern string and supplied locale.static boolean
isLocalTimeInRange
(LocalTime value, LocalTime optionalMinimum, LocalTime optionalMaximum, boolean inclusiveOfEndpoints) isLocalTimeInRange, This returns true if the specified value is inside of the specified range.static boolean
isSameLocalDate
(LocalDate first, LocalDate second) isSameLocalDate, This compares two date variables to see if their values are equal.static boolean
isSameLocalTime
(LocalTime first, LocalTime second) static boolean
isSameYearMonth
(YearMonth first, YearMonth second) isSameYearMonth, This compares two YearMonth variables to see if their values are equal.static String
localDateTimeToString, This will return the supplied LocalDateTime as a string.static String
localDateTimeToString
(LocalDateTime value, String emptyTimeString) localDateTimeToString, This will return the supplied LocalDateTime as a string.static String
localDateToString
(LocalDate date) localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd).static String
localDateToString
(LocalDate date, String emptyDateString) localDateToString, This returns the supplied date in the ISO-8601 format (uuuu-MM-dd).static String
localTimeToString
(LocalTime time) localTimeToString, This will return the supplied time as a string.static String
localTimeToString
(LocalTime time, String emptyTimeString) localTimeToString, This will return the supplied time as a string.
-
Constructor Details
-
PickerUtilities
public PickerUtilities()
-
-
Method Details
-
createFormatterFromPatternString
public static DateTimeFormatter createFormatterFromPatternString(String formatPattern, 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(LocalTime value, LocalTime optionalMinimum, 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
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. -
isSameYearMonth
isSameYearMonth, This compares two YearMonth 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 YearMonth). Or, this returns true if both of the supplied YearMonths contain a YearMonth and represent the same year and month. Otherwise this returns false. -
isSameLocalTime
-
localDateTimeToString
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
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
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
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
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
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.
-