java.lang.Object
io.github.tonywasher.joceanus.oceanus.date.OceanusDateConfig
All Implemented Interfaces:
OceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>

public class OceanusDateConfig extends Object implements OceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>
Date Configuration.
  • Constructor Details

    • OceanusDateConfig

      public OceanusDateConfig(OceanusDateFormatter pFormatter)
      Constructor.
      Parameters:
      pFormatter - the date formatter
  • Method Details

    • getEventRegistrar

      public OceanusEventRegistrar<OceanusDateEvent> getEventRegistrar()
      Description copied from interface: OceanusEventRegistrar.OceanusEventProvider
      Obtain registration object for listeners.
      Specified by:
      getEventRegistrar in interface OceanusEventRegistrar.OceanusEventProvider<OceanusDateEvent>
      Returns:
      the registrar
    • getLocale

      public Locale getLocale()
      Get the locale.
      Returns:
      the locale
    • getSelectedDate

      public OceanusDate getSelectedDate()
      Get the selected date.
      Returns:
      the Selected date
    • getEarliestDate

      public OceanusDate getEarliestDate()
      Get the earliest select-able date.
      Returns:
      the Earliest date
    • getLatestDate

      public OceanusDate getLatestDate()
      Get the latest select-able date.
      Returns:
      the Latest date
    • getCurrentMonth

      public OceanusDate getCurrentMonth()
      Get the current month.
      Returns:
      the current month
    • allowNullDateSelection

      public boolean allowNullDateSelection()
      Allow Null Date selection.
      Returns:
      true/false
    • showNarrowDays

      public boolean showNarrowDays()
      Show Narrow Days.
      Returns:
      true/false
    • setAllowed

      public void setAllowed(Predicate<OceanusDate> pAllowed)
      Set the Allowed predicate.
      Parameters:
      pAllowed - the predicate
    • isAllowed

      public boolean isAllowed(int pDay)
      Determine whether the day in the month is allowed.
      Parameters:
      pDay - the day of the current month
      Returns:
      true/false
    • setLocale

      public final void setLocale(Locale pLocale)
      Set the Locale.
      Parameters:
      pLocale - the Locale
    • setAllowNullDateSelection

      public void setAllowNullDateSelection(boolean pAllowNullDateSelection)
      Allow null date selection. If this flag is set an additional button will be displayed allowing the user to explicitly select no date, thus setting the SelectedDate to null.
      Parameters:
      pAllowNullDateSelection - true/false
    • setShowNarrowDays

      public void setShowNarrowDays(boolean pShowNarrowDays)
      Show Narrow Days. If this flag is set Days are show in narrow rather than short form.
      Parameters:
      pShowNarrowDays - true/false
    • rebuildNames

      protected final void rebuildNames()
      Rebuild names.
    • setEarliestDate

      public final void setEarliestDate(OceanusDate pEarliest)
      Set the earliest date. This is the earliest date that may be selected. If the configured latest date is earlier than this date, it will be set to this date to ensure a valid range.
      Parameters:
      pEarliest - the Earliest select-able date (or null if unlimited)
    • setLatestDate

      public final void setLatestDate(OceanusDate pLatest)
      Set the latest date. This is the latest date that may be selected. If the configured earliest date is later than this date, it will be set to this date to ensure a valid range.
      Parameters:
      pLatest - the Latest select-able date (or null if unlimited)
    • formatDate

      public String formatDate(LocalDate pDate)
      Format a date according to configured rules.
      Parameters:
      pDate - the date to format
      Returns:
      the formatted date
    • capitaliseString

      public String capitaliseString(String pValue)
      Capitalise first letter of string.
      Parameters:
      pValue - the string to capitalise the first letter of
      Returns:
      the capitalised string
    • currentDate

      public OceanusDate currentDate()
      Obtain current date.
      Returns:
      the current date
    • getCurrentDay

      public int getCurrentDay()
      Obtain current day of month or zero if not current month.
      Returns:
      the current month day
    • getSelectedDay

      public int getSelectedDay()
      Obtain Selected day of month or zero if not current month.
      Returns:
      the selected month day
    • getEarliestDay

      public int getEarliestDay()
      Obtain Earliest day of month or zero if not current month.
      Returns:
      the earliest month day
    • getLatestDay

      public int getLatestDay()
      Obtain Latest day of month or zero if not current month.
      Returns:
      the latest month day
    • previousMonth

      public void previousMonth()
      Adjust current month to previous month.
    • nextMonth

      public void nextMonth()
      Adjust current month to next month.
    • previousYear

      public void previousYear()
      Adjust current month to previous year.
    • nextYear

      public void nextYear()
      Adjust current month to next year.
    • setSelectedDate

      public final void setSelectedDate(OceanusDate pDate)
      Set the selected date.
      Parameters:
      pDate - the Selected date
    • setSelectedDay

      public void setSelectedDay(int pDay)
      Set selected day in current month (called from dialog).
      Parameters:
      pDay - the selected day
    • initialiseCurrent

      public void initialiseCurrent()
      Initialise the current month.
    • isDateChanged

      public static boolean isDateChanged(OceanusDate pFirst, OceanusDate pSecond)
      Has the date changed?
      Parameters:
      pFirst - the first date
      pSecond - the second date
      Returns:
      true/false
    • isSameMonth

      public static boolean isSameMonth(OceanusDate pFirst, OceanusDate pSecond)
      Are the dates in the same month.
      Parameters:
      pFirst - the first date (maybe null)
      pSecond - the second date
      Returns:
      true/false
    • isSameYear

      public static boolean isSameYear(OceanusDate pFirst, OceanusDate pSecond)
      Are the dates in the same year.
      Parameters:
      pFirst - the first date (maybe null)
      pSecond - the second date
      Returns:
      true/false