@Test @Templates("plain") public void testLocale() { String locale = "ru"; calendarAttributes.set(CalendarAttributes.locale, locale); DayPicker dayPicker = popupCalendar.openPopup().getDayPicker(); List<String> weekDayShortNames = dayPicker.getWeekDayShortNames(); List<String> expectedShortNames = Arrays.asList("Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"); assertEquals(weekDayShortNames, expectedShortNames); setCurrentDateWithCalendarsTodayButtonAction.perform(); DateTime parsedDateTime = dateTimeFormatter .withLocale(new Locale(locale)) .parseDateTime(popupCalendar.getInput().getStringValue()); assertEquals( parsedDateTime.getDayOfMonth(), todayMidday.getDayOfMonth(), "Input doesn't contain selected date."); assertEquals( parsedDateTime.getMonthOfYear(), todayMidday.getMonthOfYear(), "Input doesn't contain selected date."); assertEquals( parsedDateTime.getYear(), todayMidday.getYear(), "Input doesn't contain selected date."); }
/** @return */ private DateTime getDate() { String s = field.get(0).get(0).toString(); DateTimeParser[] parsers = {DateTimeFormat.forPattern("yyyMMMddHH").getParser()}; DateTimeFormatter inputFormatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); return inputFormatter.withLocale(Locale.US).parseDateTime(s); }
public void onDateSet(DatePicker view, int year, int month, int day) { // Do something with the date chosen by the user DateTime date = new DateTime(year, month, day, 0, 0); DateTimeFormatter formatter = DateTimeFormat.forPattern("EEEE dd MMMM yyyy"); formatter.withLocale(Locale.FRENCH); if (isFromDate) { fromDateTextView.setText(formatter.print(date)); } else { toDateTextView.setText(formatter.print(date)); } }
protected final DateTimeFormatter doDateTimeFormatter(DateTimeFormatter input) { return cfg.timeZone == null ? input.withLocale(cfg.locale).withZoneUTC() : input.withLocale(cfg.locale).withZone(cfg.timeZone); }
/** * Sets the locale to use for formatting the time. * * @param locale locale to use for formatting * @return self, for chaining */ public TimeFormatter withLocale(Locale locale) { dtf = dtf.withLocale(locale); return this; }
/** * @param text The text representing a date and time in SMTP format (e.g. "01 Jan 2000") in UTC * @param locale The specific local to use * @return The DateTime in the UTC timezone for the given locale * @throws IllegalArgumentException If the text cannot be parsed */ public static DateTime parseSmtpUtc(String text, Locale locale) { return utcSmtpDateFormatter.withLocale(locale).parseDateTime(text); }
/** * @param when The instant * @param locale The required locale * @return The instant formatted as ISO8601 e.g. "2000-01-02T03:04:05Z" in UTC */ public static String formatIso8601(ReadableInstant when, Locale locale) { if (when == null) { return ""; } return utcIso8601.withLocale(locale).print(when); }
/** * @param when The instant * @param locale The required locale * @return The instant formatted for SMTP as defined in RFC 1123 e.g. "dd MMM yyyy" (01 Jan 2000) * in UTC */ public static String formatSmtpDate(ReadableInstant when, Locale locale) { if (when == null) { return ""; } return utcSmtpDateFormatter.withLocale(locale).print(when); }