Example usage for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat

List of usage examples for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat.

Prototype

public ISO8601DateFormat() 

Source Link

Usage

From source file:com.example.mego.adas.videos.api.YouTubeApiUtilities.java

/**
 * return a DataSend object to parse it to extract the time and date
 *///  w w  w . j  a va2s  .  c o m
public static Date fromISO8601(String publishedDate) {
    Date date = null;
    ISO8601DateFormat dateFormat = new ISO8601DateFormat();
    try {
        date = dateFormat.parse(publishedDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:eu.openminted.registry.service.generate.WorkflowOutputMetadataGenerate.java

public WorkflowOutputMetadataGenerate() {
    mapper = new ObjectMapper();
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    mapper.setDateFormat(new ISO8601DateFormat());
    gregory = new GregorianCalendar();
    gregory.setTime(new java.util.Date());
}

From source file:org.apache.unomi.persistence.spi.CustomObjectMapper.java

public CustomObjectMapper() {
    super();// w ww  .jav a  2s  . c  o  m
    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);
}

From source file:com.ethercis.vehr.response.JsonHttpResponse.java

public void respond(Object data, String path) throws IOException {

    //do some substitutions
    if (data instanceof Map) {
        Map contentMap = (Map) data;
        if (contentMap.containsKey("meta")) {
            data = MetaBuilder.substituteVarMetaMap(contentMap, Constants.URI_TAG, path);
        }//  ww  w. j a  v a 2  s .  c o  m
        if (contentMap.containsKey("headers")) {
            I_SessionClientProperties props = (I_SessionClientProperties) contentMap.get("headers");
            for (String s : props.clientProps2StringMap().keySet()) {
                setHeader(s, props.getClientProperty(s, ""));
            }
            contentMap.remove("headers"); //do not serialize in body
        }
    }

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setDateFormat(new ISO8601DateFormat());

    String bodyContent = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
    setContentLength(bodyContent.getBytes().length);
    writer.println(bodyContent);
    writer.close();
}

From source file:io.gumga.security.WebConfigForTest.java

private MappingJackson2HttpMessageConverter jacksonConverter() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Hibernate4Module());
    mapper.registerModule(new JodaModule());
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    mapper.setDateFormat(new ISO8601DateFormat());
    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

    MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    jacksonConverter.setObjectMapper(mapper);

    return jacksonConverter;
}

From source file:com.nissatech.proasense.eventplayer.partnerconfigurations.HellaConfiguration.java

/**
 * {@inheritDoc}//from  ww w.  ja  v a 2  s  . co m
 */
@Override
public String generateMessage(Row row) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.setDateFormat(new ISO8601DateFormat());
    HashMap message = new HashMap();
    DateTime date = new DateTime(row.getDate("variable_timestamp"));
    message.put("variable_timestamp", date);
    message.put("values", row.getMap("values", String.class, String.class));
    message.put("variable_type", row.getString("variable_type"));
    return mapper.writeValueAsString(message);

}

From source file:com.groupon.jackson.ObjectMapperFactory.java

private static ObjectMapper createModifiableObjectMapper(final String name, final ObjectMapper objectMapper) {
    final SimpleModule module = new SimpleModule(name);
    objectMapper.registerModule(module);
    objectMapper.registerModule(new GuavaModule());
    objectMapper.registerModule(new Jdk7Module());
    objectMapper.registerModule(new Jdk8Module());
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.WRAP_EXCEPTIONS, false);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    objectMapper.setDateFormat(new ISO8601DateFormat());
    return objectMapper;
}

From source file:com.nissatech.proasense.eventplayer.partnerconfigurations.HellaConfiguration.java

/**
 * {@inheritDoc}/*from w ww .j  a  v  a 2 s . c o m*/
 */
@Override
public String generateBatch(ResultSet rows) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.setDateFormat(new ISO8601DateFormat());
    List<HashMap> batch = new ArrayList<HashMap>();
    for (Row row : rows) {
        HashMap message = new HashMap();
        DateTime date = new DateTime(row.getDate("variable_timestamp"));
        message.put("variable_timestamp", date);
        message.put("values", row.getMap("values", String.class, String.class));
        message.put("variable_type", row.getString("variable_type"));
        batch.add(message);
    }
    return mapper.writeValueAsString(batch);
}

From source file:com.evrythng.java.wrapper.util.JSONUtils.java

/**
 * Creates a pre-configured {@link ObjectMapper}.
 *///from   w  ww . j  a  va2s. c  om
public static ObjectMapper createObjectMapper() {

    ObjectMapper mapper = new ObjectMapper();

    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
    mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setDateFormat(new ISO8601DateFormat());

    mapper.registerModule(new CoreModule());

    return mapper;
}

From source file:de.brendamour.jpasskit.signing.PKSigningUtil.java

public static byte[] createSignedAndZippedPkPassArchive(final PKPass pass, final String pathToTemplateDirectory,
        final PKSigningInformation signingInformation) throws Exception {

    File tempPassDir = Files.createTempDir();
    FileUtils.copyDirectory(new File(pathToTemplateDirectory), tempPassDir);

    ObjectMapper jsonObjectMapper = new ObjectMapper();
    jsonObjectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    jsonObjectMapper.setDateFormat(new ISO8601DateFormat());

    createPassJSONFile(pass, tempPassDir, jsonObjectMapper);

    File manifestJSONFile = createManifestJSONFile(tempPassDir, jsonObjectMapper);

    signManifestFile(tempPassDir, manifestJSONFile, signingInformation);

    byte[] zippedPass = createZippedPassAndReturnAsByteArray(tempPassDir);

    FileUtils.deleteDirectory(tempPassDir);
    return zippedPass;
}