com.fasterxml.jackson.databind.util.ISO8601DateFormat Java Examples

The following examples show how to use com.fasterxml.jackson.databind.util.ISO8601DateFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfService.java    From SkaETL with Apache License 2.0 5 votes vote down vote up
public void createConfiguration(ConfigurationLogstash configurationLogstash) {
    ISO8601DateFormat df = new ISO8601DateFormat();
    Date newDate = new Date();
    configurationLogstash.setTimestamp(df.format(newDate));
    configurationLogstash.setIdConfiguration(UUID.randomUUID().toString());
    configurationLogstash.setStatusConfig(StatusConfig.INIT);
    map.put(configurationLogstash.getIdConfiguration(), configurationLogstash);
}
 
Example #2
Source File: JSONUtils.java    From SkaETL with Apache License 2.0 5 votes vote down vote up
private JSONUtils() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    objectMapper.setDateFormat(new ISO8601DateFormat());
}
 
Example #3
Source File: ESErrorRetryWriter.java    From SkaETL with Apache License 2.0 5 votes vote down vote up
private ErrorData toErrorData(ValidateData validateData) {
    ISO8601DateFormat df = new ISO8601DateFormat();
    return ErrorData.builder()
            .errorReason(validateData.getStatusCode().name())
            .errorMessage(validateData.getMessage())
            .typeValidation(validateData.getTypeValidation().name())
            .message(validateData.getMessage())
            .timestamp(df.format(new Date()))
            .build();
}
 
Example #4
Source File: AbstractElasticsearchProcessor.java    From SkaETL with Apache License 2.0 5 votes vote down vote up
private void produceErrorToKafka(String messageFailure, String value) {
    ISO8601DateFormat df = new ISO8601DateFormat();
    ErrorData error = ErrorData.builder()
            .errorReason(StatusCode.error_after_send_es.name())
            .errorMessage(messageFailure)
            .message(value)
            .timestamp(df.format(new Date()))
            .build();
    esErrorRetryWriter.sendToErrorTopic(getApplicationId(), error);
}
 
Example #5
Source File: OpenLRW.java    From OpenLRW with Educational Community License v2.0 5 votes vote down vote up
@Bean
public ObjectMapper objectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.findAndRegisterModules();
    mapper.setDateFormat(new ISO8601DateFormat());
    mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    return mapper;
}
 
Example #6
Source File: EventServiceTest.java    From OpenLRW with Educational Community License v2.0 5 votes vote down vote up
@Before
public void init() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException {
  
  if (savedTenant == null) {
    Tenant tenant = new Tenant.Builder().withId("test-tid").withName("test").build();
    savedTenant = tenantRepository.save(tenant);
  }
  
  if (mongoOrg == null) {
    Org org = new Org.Builder().withSourcedId("org-id").withName("org").build();
    
    mongoOrg = new MongoOrg.Builder()
               .withOrg(org)
               .withTenantId(savedTenant.getId())
               .withApiKey(UUID.randomUUID().toString())
               .withApiSecret(UUID.randomUUID().toString())
               .build();
    
    mongoOrgRepository.save(mongoOrg);
  }
  
  if (event == null || mediaEvent == null) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.findAndRegisterModules();
    mapper.setDateFormat(new ISO8601DateFormat());
    Envelope envelope = mapper.readValue(MediaEventTest.MEDIA_EVENT.getBytes("UTF-8"), Envelope.class);
    mediaEvent = envelope.getData().get(0);
    
    Envelope envelope1 = mapper.readValue(MinimalEventTest.MINIMAL_VIEWED_EVENT.getBytes("UTF-8"), Envelope.class);
    event = envelope1.getData().get(0);
  }
  
}
 
Example #7
Source File: MongoEventRepositoryTest.java    From OpenLRW with Educational Community License v2.0 5 votes vote down vote up
@Before
public void init() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException {
  ObjectMapper mapper = new ObjectMapper();
  mapper.findAndRegisterModules();
  mapper.setDateFormat(new ISO8601DateFormat());

  Envelope envelope = mapper.readValue(MediaEventTest.MEDIA_EVENT.getBytes("UTF-8"), Envelope.class);
  mediaEvent = envelope.getData().get(0);
}
 
Example #8
Source File: ToJson.java    From incubator-taverna-language with Apache License 2.0 5 votes vote down vote up
public ToJson() {
	mapper.enable(SerializationFeature.INDENT_OUTPUT);
	mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
	mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

	mapper.setDateFormat(new ISO8601DateFormat());

	// Adding custom writer dynamically
	List<WorkflowBundleWriter> writers = io.getWriters();
	writers.add(jsonWriter);
	io.setWriters(writers);
}
 
Example #9
Source File: JsonExport.java    From incubator-taverna-language with Apache License 2.0 5 votes vote down vote up
public JsonExport() {
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    mapper.setDateFormat(new ISO8601DateFormat());
    
    // Adding custom writer dynamically
    List<WorkflowBundleWriter> writers = io.getWriters();
    writers.add(jsonWriter);        
    io.setWriters(writers);
}
 
Example #10
Source File: SoaInfo.java    From soabase with Apache License 2.0 5 votes vote down vote up
public static DateFormat newUtcFormatter()
{
    TimeZone tz = TimeZone.getTimeZone("UTC");
    ISO8601DateFormat df = new ISO8601DateFormat();
    df.setTimeZone(tz);
    return df;
}
 
Example #11
Source File: ToJsonSpec.java    From javalite with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnSecondsInDateTime() throws ParseException {
    Person p = new Person();
    p.set("name", "john", "last_name", "doe").saveIt();
    p.refresh();
    String json = p.toJson(true);

    System.out.println(json);
    @SuppressWarnings("unchecked")
    Map<String, String> map = JsonHelper.toMap(json);

    Date d = new ISO8601DateFormat().parse(map.get("created_at"));
    // difference between date in Json and in original model instance should be less than 1000 milliseconds
    a(Math.abs(d.getTime() - p.getTimestamp("created_at").getTime()) < 1000L).shouldBeTrue();
}
 
Example #12
Source File: ConfService.java    From SkaETL with Apache License 2.0 4 votes vote down vote up
public void editConfiguration(ConfigurationLogstash configurationLogstash) {
    ISO8601DateFormat df = new ISO8601DateFormat();
    Date newDate = new Date();
    configurationLogstash.setTimestamp(df.format(newDate));
    map.put(configurationLogstash.getIdConfiguration(), configurationLogstash);
}
 
Example #13
Source File: StashUtil.java    From emodb with Apache License 2.0 4 votes vote down vote up
public static Date getStashCreationTimeStamp(String stashStartTime) throws ParseException {
    return new ISO8601DateFormat().parse(stashStartTime);
}
 
Example #14
Source File: ChronosMapper.java    From chronos with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public ChronosMapper() {
  this.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
    .registerModule(new JodaModule())
    .setDateFormat(new ISO8601DateFormat());
}