List of usage examples for com.fasterxml.jackson.databind.util ISO8601DateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:io.soabase.core.SoaInfo.java
public static DateFormat newUtcFormatter() { TimeZone tz = TimeZone.getTimeZone("UTC"); ISO8601DateFormat df = new ISO8601DateFormat(); df.setTimeZone(tz); return df;/*from w ww .j ava 2 s . c om*/ }
From source file:io.soabase.core.rest.SoaApis.java
@GET @Produces(MediaType.APPLICATION_JSON)// w ww.ja v a 2s. co m public Info getInfo() { TimeZone tz = TimeZone.getTimeZone("UTC"); ISO8601DateFormat df = new ISO8601DateFormat(); df.setTimeZone(tz); String now = df.format(new Date()); String start = df.format(new Date(soaInfo.getStartTimeMs())); return new Info(soaInfo.getScopes(), soaInfo.getMainPort(), soaInfo.getAdminPort(), soaInfo.getServiceName(), soaInfo.getInstanceName(), start, now); }
From source file:org.apache.unomi.persistence.spi.CustomObjectMapper.java
public CustomObjectMapper() { super();/*from w w w. j a va2s . c om*/ super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule = new SimpleModule("PropertyTypedObjectDeserializerModule", new Version(1, 0, 0, null, "org.apache.unomi.rest", "deserializer")); PropertyTypedObjectDeserializer propertyTypedObjectDeserializer = new PropertyTypedObjectDeserializer(); propertyTypedObjectDeserializer.registerMapping("type=.*Condition", Condition.class); deserializerModule.addDeserializer(Object.class, propertyTypedObjectDeserializer); ItemDeserializer itemDeserializer = new ItemDeserializer(); deserializerModule.addDeserializer(Item.class, itemDeserializer); Map<String, Class<? extends Item>> classes = new HashMap<>(); classes.put(Campaign.ITEM_TYPE, Campaign.class); classes.put(CampaignEvent.ITEM_TYPE, CampaignEvent.class); classes.put(Event.ITEM_TYPE, Event.class); classes.put(Goal.ITEM_TYPE, Goal.class); classes.put(Persona.ITEM_TYPE, Persona.class); classes.put(Rule.ITEM_TYPE, Rule.class); classes.put(Scoring.ITEM_TYPE, Scoring.class); classes.put(Segment.ITEM_TYPE, Segment.class); classes.put(Session.ITEM_TYPE, Session.class); classes.put(ConditionType.ITEM_TYPE, ConditionType.class); classes.put(ActionType.ITEM_TYPE, ActionType.class); for (Map.Entry<String, Class<? extends Item>> entry : classes.entrySet()) { propertyTypedObjectDeserializer.registerMapping("itemType=" + entry.getKey(), entry.getValue()); itemDeserializer.registerMapping(entry.getKey(), entry.getValue()); } propertyTypedObjectDeserializer.registerMapping("itemType=.*", CustomItem.class); super.registerModule(deserializerModule); }