APISonar


org.springframework.format.annotation.DateTimeFormat.ISO.DATE

> org > springframework > format > annotation > DateTimeFormat > ISO > DATE
org APIs springframework APIs format APIs annotation APIs DateTimeFormat APIs ISO APIs DATE APIs

Example 1
public void shouldPrintAndParseISODate() throws Exception {
		DateFormatter formatter = new DateFormatter();
		formatter.setTimeZone(UTC);
		formatter.setIso(ISO.DATE);
		Date date = getDate(2009, Calendar.JUNE, 1, 14, 23, 5, 3);
		assertThat(formatter.print(date, Locale.US)).isEqualTo("2009-06-01");
		assertThat(formatter.parse("2009-6-01", Locale.US))
				.isEqualTo(getDate(2009, Calendar.JUNE, 1));
	}
Example 2
public void createDateTimeFormatterInOrderOfPropertyPriority() {
		factory.setStylePattern("SS");
		String value = applyLocale(factory.createDateTimeFormatter()).format(dateTime);
		assertThat(value.startsWith("10/21/09")).isTrue();
		assertThat(value.endsWith("12:10 PM")).isTrue();

		factory.setIso(ISO.DATE);
		assertThat(applyLocale(factory.createDateTimeFormatter()).format(dateTime)).isEqualTo("2009-10-21");

		factory.setPattern("yyyyMMddHHmmss");
		assertThat(factory.createDateTimeFormatter().format(dateTime)).isEqualTo("20091021121000");
	}
Example 3
private DateTimeFormatter forIso(ISO iso) {
		if (iso == ISO.DATE) {
			return org.joda.time.format.ISODateTimeFormat.date();
		}
		else if (iso == ISO.TIME) {
			return org.joda.time.format.ISODateTimeFormat.time();
		}
		else {
			return org.joda.time.format.ISODateTimeFormat.dateTime();
		}		
	}
Example 4
public void bindWhenHasAnnotationsShouldChangeConvertedValue() throws Exception {
		this.sources.add(new MockConfigurationPropertySource("foo", "2014-04-01"));
		DateTimeFormat annotation = AnnotationUtils.synthesizeAnnotation(
				Collections.singletonMap("iso", DateTimeFormat.ISO.DATE),
				DateTimeFormat.class, null);
		LocalDate result = this.binder
				.bind("foo", Bindable.of(LocalDate.class).withAnnotations(annotation))
				.get();
		assertThat(result.toString()).isEqualTo("2014-04-01");
	}