Java Utililty Methods DateTimeFormatter

List of utility methods to do DateTimeFormatter

Description

The list of methods to do DateTimeFormatter are organized into topic(s).

Method

DateTimeFormattergetFullFormatter()
get Full Formatter
return DateTimeFormatter.ofPattern(FULL_PATTERN).withLocale(Locale.FRANCE);
DateTimeFormattergetGermanFormatter()
get German Formatter
return germanFormatter;
ChronoUnitgetIndexGroupingPeriod_slow(String date_format)
Utility function to figure out the grouping period based on the index name
final SimpleDateFormat d = new SimpleDateFormat(date_format);
final long try_date_boxes[] = { 3601L, 25L * 3600L, 8L * 24L * 3600L, 32L * 24L * 3600L,
        367L * 34L * 3600L };
final ChronoUnit ret_date_boxes[] = { ChronoUnit.HOURS, ChronoUnit.DAYS, ChronoUnit.WEEKS,
        ChronoUnit.MONTHS, ChronoUnit.YEARS };
final Date now = new Date();
final String now_string = d.format(now);
for (int i = 0; i < try_date_boxes.length; ++i) {
...
DateTimeFormattergetLocalizedDateFormat(final Locale LOCALE)
get Localized Date Format
return DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).withLocale(LOCALE);
LocalTimegetParsedTimeOrNull(String timeText, DateTimeFormatter formatForDisplayTime, DateTimeFormatter formatForMenuTimes, ArrayList formatsForParsing, Locale timePickerLocale)
get Parsed Time Or Null
if (timeText == null || timeText.trim().isEmpty()) {
    return null;
timeText = timeText.trim().toLowerCase();
LocalTime parsedTime = null;
if (parsedTime == null) {
    try {
        parsedTime = LocalTime.parse(timeText, formatForDisplayTime);
...
DateTimeFormattergetPreferredDateFormat()
get Preferred Date Format
return preferredDateFormat;
DateTimeFormattergetShortDateManualEntryFormatter()
get Short Date Manual Entry Formatter
return shortDateManualEntryFormatter;
DateTimeFormattergetShortFormatter(Locale locale)
get Short Formatter
String pattern = SHORT_PATTERN_EN;
if (Locale.FRANCE.equals(locale))
    pattern = SHORT_PATTERN_FR;
return DateTimeFormatter.ofPattern(pattern);
DategetStartOfDay(Date dateToFormat)
Retuns the start of day in Date format.
assert dateToFormat != null : "Date to be formatted should not be null";
LocalDate date = dateToFormat.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
LocalTimegetTime(final String time, final DateTimeFormatter formatter)
get Time
return time != null ? LocalTime.parse(time, formatter) : null;