Module MaterialFX

Class DateTimeUtils

java.lang.Object
io.github.palexdev.materialfx.utils.DateTimeUtils

public class DateTimeUtils extends Object
Utils class for Java's time API.
  • Field Details

  • Method Details

    • partialIntMonthMatrix

      public static Integer[][] partialIntMonthMatrix(Locale locale, YearMonth yearMonth)
      Builds a bi-dimensional array of integers (6 rows x 7 columns) that contains only the days of the month specified by the given YearMonth.

      That means that at most 31 positions will contain a day, the others will contain null.
    • partialDayMonthMatrix

      public static DateTimeUtils.Day[][] partialDayMonthMatrix(Locale locale, YearMonth yearMonth)
      Builds a bi-dimensional array of DateTimeUtils.Days (6 rows x 7 columns) that contains only the days of the month specified by the given YearMonth.

      That means that at most 31 positions will contain a day, the others will contain null.
    • fullIntMonthMatrix

      public static Integer[][] fullIntMonthMatrix(Locale locale, YearMonth yearMonth)
      Builds a bi-dimensional array of integers (6 rows x 7 columns) that completely fills the matrix. Empty positions will contain the days belonging the the previous/next month.
    • fullDayMonthMatrix

      public static DateTimeUtils.Day[][] fullDayMonthMatrix(Locale locale, YearMonth yearMonth)
      Builds a bi-dimensional array of DateTimeUtils.Days (6 rows x 7 columns) that completely fills the matrix. Empty positions will contain the days belonging the the previous/next month.
    • startIndexFor

      public static int startIndexFor(YearMonth yearMonth, Locale locale)
      Builds a map containing the week days according to the given locale, see weekDays(Locale) for further info. Then gets the starting DayOfWeek for the given month, and queries the map with it.

      The result is the index at which the month starts.

    • endIndexFor

      public static int endIndexFor(YearMonth yearMonth, Locale locale)
      Computes the index at which the month ends, by computing the starting index, startIndexFor(YearMonth, Locale), and then adding the length of the month to the result - 1.
    • weekDays

      public static Map<DayOfWeek,Integer> weekDays(Locale locale)
      The DayOfWeek enumerator assumes that Monday is the first day of the week. This however depends on the country (locale).

      This method generates a Map associating each DayOfWeek to its position in the week.

      So, for example for the US locale, Sunday which is the seventh DayOfWeek is associated to 1, since the week starts with Sunday.

    • dateToYearMonth

      public static YearMonth dateToYearMonth(LocalDate date)
      Converts the given LocalDate to a YearMonth.