コード例 #1
0
 @Test
 public void testTimeEntityToStringReturnsFormattedGMTDateTime() throws Exception {
   Date then = new Date(123456789012L);
   TimeEntity aTime = new TimeEntity(then);
   aTime.setTz(TimeZone.getTimeZone("GMT"));
   DateFormatter formatter = new DateFormatter("MM/dd/yyyy hh:mm:ss");
   formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
   String expected = formatter.print(then, Locale.getDefault());
   assertEquals(expected, aTime.toString());
 }
コード例 #2
0
ファイル: RootConfig.java プロジェクト: jpukg/wstream
 @Bean
 public FormattingConversionService conversionService() {
   DefaultFormattingConversionService conversionService =
       new DefaultFormattingConversionService(false);
   conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
   DateFormatterRegistrar registrar = new DateFormatterRegistrar();
   DateFormatter dateFormatter = new DateFormatter();
   dateFormatter.setIso(ISO.DATE);
   registrar.setFormatter(dateFormatter);
   registrar.registerFormatters(conversionService);
   return conversionService;
 }
 protected Formatter<Date> getFormatter(DateTimeFormat annotation, Class<?> fieldType) {
   DateFormatter formatter = new DateFormatter();
   formatter.setPattern(dateTimePattern);
   return formatter;
 }