DateTimeUtils { public static DatePickerDetails getDatePickerDetails(String appearance) { DatePickerDetails.DatePickerType datePickerType = DatePickerDetails.DatePickerType.GREGORIAN; DatePickerDetails.DatePickerMode datePickerMode = DatePickerDetails.DatePickerMode.CALENDAR; if (appearance != null) { appearance = appearance.toLowerCase(Locale.US); if (appearance.contains(WidgetAppearanceUtils.ETHIOPIAN)) { datePickerType = DatePickerDetails.DatePickerType.ETHIOPIAN; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.COPTIC)) { datePickerType = DatePickerDetails.DatePickerType.COPTIC; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.ISLAMIC)) { datePickerType = DatePickerDetails.DatePickerType.ISLAMIC; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.BIKRAM_SAMBAT)) { datePickerType = DatePickerDetails.DatePickerType.BIKRAM_SAMBAT; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.MYANMAR)) { datePickerType = DatePickerDetails.DatePickerType.MYANMAR; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.PERSIAN)) { datePickerType = DatePickerDetails.DatePickerType.PERSIAN; datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } else if (appearance.contains(WidgetAppearanceUtils.NO_CALENDAR)) { datePickerMode = DatePickerDetails.DatePickerMode.SPINNERS; } if (appearance.contains(WidgetAppearanceUtils.MONTH_YEAR)) { datePickerMode = DatePickerDetails.DatePickerMode.MONTH_YEAR; } else if (appearance.contains(WidgetAppearanceUtils.YEAR)) { datePickerMode = DatePickerDetails.DatePickerMode.YEAR; } } return new DatePickerDetails(datePickerType, datePickerMode); } private  DateTimeUtils(); static String getDateTimeLabel(Date date, DatePickerDetails datePickerDetails, boolean containsTime, Context context); static LocalDateTime skipDaylightSavingGapIfExists(LocalDateTime date); static DatePickerDetails getDatePickerDetails(String appearance); static long tsToSec8601(String timestamp); static String formatDateFromServer(String time); static String getRelativeTime(String dateTime, Boolean dateTimeFromServer); static String getFormattedDate(String format, long time);  }
@Test public void getDatePickerDetailsTest() { assertEquals(gregorian, DateTimeUtils.getDatePickerDetails(null)); String appearance = "something"; assertEquals(gregorian, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "no-calendar"; assertEquals(gregorianSpinners, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "NO-CALENDAR"; assertEquals(gregorianSpinners, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year"; assertEquals(gregorianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "MONTH-year"; assertEquals(gregorianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year"; assertEquals(gregorianYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Year"; assertEquals(gregorianYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "ethiopian"; assertEquals(ethiopian, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Ethiopian month-year"; assertEquals(ethiopianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year ethiopian"; assertEquals(ethiopianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Ethiopian year"; assertEquals(ethiopianYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year ethiopian"; assertEquals(ethiopianYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "coptic"; assertEquals(coptic, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Coptic month-year"; assertEquals(copticMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year coptic"; assertEquals(copticMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Coptic year"; assertEquals(copticYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year coptic"; assertEquals(copticYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "islamic"; assertEquals(islamic, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Islamic month-year"; assertEquals(islamicMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year islamic"; assertEquals(islamicMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Islamic year"; assertEquals(islamicYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year islamic"; assertEquals(islamicYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "bikram-sambat"; assertEquals(bikramSambat, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Bikram-sambat month-year"; assertEquals(bikramSambatMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year bikram-sambat"; assertEquals(bikramSambatMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Bikram-sambat year"; assertEquals(bikramSambatYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year bikram-sambat"; assertEquals(bikramSambatYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "myanmar"; assertEquals(myanmar, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Myanmar month-year"; assertEquals(myanmarMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year myanmar"; assertEquals(myanmarMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Myanmar year"; assertEquals(myanmarYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year myanmar"; assertEquals(myanmarYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "persian"; assertEquals(persian, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Persian month-year"; assertEquals(persianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "month-year persian"; assertEquals(persianMonthYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "Persian year"; assertEquals(persianYear, DateTimeUtils.getDatePickerDetails(appearance)); appearance = "year persian"; assertEquals(persianYear, DateTimeUtils.getDatePickerDetails(appearance)); }