本文整理汇总了Java中org.springframework.format.datetime.joda.DateTimeFormatterFactory类的典型用法代码示例。如果您正苦于以下问题:Java DateTimeFormatterFactory类的具体用法?Java DateTimeFormatterFactory怎么用?Java DateTimeFormatterFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateTimeFormatterFactory类属于org.springframework.format.datetime.joda包,在下文中一共展示了DateTimeFormatterFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jacksonJodaModule
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
@Bean
public JodaModule jacksonJodaModule() {
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaFormat(formatterFactory.createDateTimeFormatter()
.withZoneUTC())));
return module;
}
示例2: convertObjectToJsonBytes
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object)
throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaFormat(formatterFactory.createDateTimeFormatter()
.withZoneUTC())));
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
示例3: jacksonJodaModule
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
@Bean
public JodaModule jacksonJodaModule() {
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaDateFormat(formatterFactory.createDateTimeFormatter().withZoneUTC())));
return module;
}
示例4: jacksonJodaModule
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
@Bean
public JodaModule jacksonJodaModule() {
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaDateFormat(formatterFactory.createDateTimeFormatter()
.withZoneUTC())));
return module;
}
示例5: convertObjectToJsonBytes
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
/**
* Convert an object to JSON byte array.
*
* @param object
* the object to convert
* @return the JSON byte array
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object)
throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaDateFormat(formatterFactory.createDateTimeFormatter()
.withZoneUTC())));
mapper.registerModule(module);
return mapper.writeValueAsBytes(object);
}
示例6: jacksonJodaModule
import org.springframework.format.datetime.joda.DateTimeFormatterFactory; //导入依赖的package包/类
@Bean
public JodaModule jacksonJodaModule() {
JodaModule module = new JodaModule();
DateTimeFormatterFactory formatterFactory = new DateTimeFormatterFactory();
formatterFactory.setIso(DateTimeFormat.ISO.DATE);
module.addSerializer(DateTime.class, new DateTimeSerializer(
new JacksonJodaFormat(formatterFactory.createDateTimeFormatter()
.withZoneUTC())));
return module;
}