List of usage examples for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat
public ISO8601DateFormat()
From source file:org.apache.taverna.tavlang.tools.convert.ToJson.java
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);//ww w .j av a 2 s . c o m io.setWriters(writers); }
From source file:org.apache.taverna.examples.JsonExport.java
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);//from ww w . ja va2 s . c om io.setWriters(writers); }
From source file:org.javalite.activejdbc.ToJsonSpec.java
@Test public void shouldReturnSecondsInDateTime() throws ParseException { Person p = new Person(); p.set("name", "john", "last_name", "doe").saveIt(); p.refresh();/*from www . ja va 2s . co m*/ 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(); }
From source file:de.brendamour.jpasskit.signing.PKAbstractSIgningUtil.java
protected ObjectWriter configureObjectMapper(final ObjectMapper jsonObjectMapper) { jsonObjectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); jsonObjectMapper.setDateFormat(new ISO8601DateFormat()); SimpleFilterProvider filters = new SimpleFilterProvider(); // haven't found out, how to stack filters. Copying the validation one for now. filters.addFilter("validateFilter", SimpleBeanPropertyFilter.serializeAllExcept("valid", "validationErrors")); filters.addFilter("pkPassFilter", SimpleBeanPropertyFilter.serializeAllExcept("valid", "validationErrors", "foregroundColorAsObject", "backgroundColorAsObject", "labelColorAsObject", "passThatWasSet")); filters.addFilter("barcodeFilter", SimpleBeanPropertyFilter.serializeAllExcept("valid", "validationErrors", "messageEncodingAsString")); filters.addFilter("charsetFilter", SimpleBeanPropertyFilter.filterOutAllExcept("name")); jsonObjectMapper.setSerializationInclusion(Include.NON_NULL); jsonObjectMapper.addMixIn(Object.class, ValidateFilterMixIn.class); jsonObjectMapper.addMixIn(PKPass.class, PkPassFilterMixIn.class); jsonObjectMapper.addMixIn(PKBarcode.class, BarcodeFilterMixIn.class); jsonObjectMapper.addMixIn(Charset.class, CharsetFilterMixIn.class); return jsonObjectMapper.writer(filters); }
From source file:com.arpnetworking.logback.StenoEncoder.java
StenoEncoder(final JsonFactory jsonFactory, final ObjectMapper objectMapper) { // Initialize object mapper; _objectMapper = objectMapper;/*from w ww .java 2s . com*/ _objectMapper.setAnnotationIntrospector(new StenoAnnotationIntrospector()); final SimpleFilterProvider simpleFilterProvider = new SimpleFilterProvider(); simpleFilterProvider.addFilter(RedactionFilter.REDACTION_FILTER_ID, new RedactionFilter(!DEFAULT_REDACT_NULL)); // Initialize this here based on the above code, if it was initialized at the declaration site then things // could get out of sync _redactEnabled = true; _objectMapper.setFilters(simpleFilterProvider); // Setup writing of Date/DateTime values _objectMapper.registerModule(new JodaModule()); _objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); _objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); _objectMapper.setDateFormat(new ISO8601DateFormat()); // Setup other common modules _objectMapper.registerModule(new AfterburnerModule()); _objectMapper.registerModule(new Jdk7Module()); _objectMapper.registerModule(new Jdk8Module()); _objectMapper.registerModule(new GuavaModule()); // Serialization strategies _listsSerialziationStrategy = new ListsSerialziationStrategy(this, jsonFactory, _objectMapper); _objectAsJsonSerialziationStrategy = new ObjectAsJsonSerialziationStrategy(this, jsonFactory, _objectMapper); _objectSerialziationStrategy = new ObjectSerialziationStrategy(this, jsonFactory, _objectMapper); _mapOfJsonSerialziationStrategy = new MapOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper); _mapSerialziationStrategy = new MapSerialziationStrategy(this, jsonFactory, _objectMapper); _arrayOfJsonSerialziationStrategy = new ArrayOfJsonSerialziationStrategy(this, jsonFactory, _objectMapper); _arraySerialziationStrategy = new ArraySerialziationStrategy(this, jsonFactory, _objectMapper); _standardSerializationStrategy = new StandardSerializationStrategy(this, jsonFactory, _objectMapper); }
From source file:com.github.tomakehurst.wiremock.AdminApiTest.java
@Test public void getLoggedRequestsWithLimitAndSinceDate() throws Exception { for (int i = 1; i <= 5; i++) { testClient.get("/received-request/" + i); }/*ww w.j a v a 2s .com*/ String midPoint = new ISO8601DateFormat().format(new Date()); for (int i = 6; i <= 9; i++) { testClient.get("/received-request/" + i); } String body = testClient.get("/__admin/requests?since=" + midPoint + "&limit=3").content(); JsonVerifiable check = JsonAssertion.assertThat(body); check.field("meta").field("total").isEqualTo(9); check.field("requests").hasSize(3); check.field("requests").elementWithIndex(0).field("request").field("url").isEqualTo("/received-request/9"); check.field("requests").elementWithIndex(2).field("request").field("url").isEqualTo("/received-request/7"); }
From source file:org.craftercms.studio.impl.v1.util.ContentUtils.java
public static Date getEditedDate(String str) { if (!StringUtils.isEmpty(str)) { try {/* w w w .j a v a2 s . c o m*/ return (new ISO8601DateFormat()).parse(str); } catch (ParseException e) { logger.error("No activity post date provided."); return null; } } else { logger.error("No activity post date provided."); return null; } }
From source file:org.opencommercesearch.client.ProductApi.java
private void initMapper() { mapper = new ObjectMapper().setDateFormat(new ISO8601DateFormat()) .setSerializationInclusion(JsonInclude.Include.NON_NULL); SimpleModule module = new SimpleModule("InterfaceMapper"); module.addAbstractTypeMapping(Product.class, DefaultProduct.class); mapper.registerModule(module);/*from www . ja va 2s . com*/ }
From source file:org.opencommercesearch.client.ProductApiTest.java
private void validateProducts(Product[] products) { assertEquals("Products in current page match", 10, products.length); Product firstProduct = products[0];/*from w w w .j av a 2 s .c o m*/ assertNotNull(firstProduct); assertEquals("CST0180", firstProduct.getId()); assertEquals("Goccia Rain Jacket ", firstProduct.getTitle()); assertEquals( "<p>Dont let a little sprinkle stop your ride. Just pull on the Castelli Goccia Rain Jacket and get after it. Waterproof, breathable Torrent fabric keeps you dry while a back vent helps the heat escape. Reflective Castelli graphics make you more visible when riding in traffic.</p>", firstProduct.getDescription()); assertEquals( "Dont let a little sprinkle stop your ride. Just pull on the Castelli Mens Goccia Rain Jacket and get after it.", firstProduct.getShortDescription()); assertEquals("557", firstProduct.getSizingChart()); assertEquals(Integer.valueOf(1), firstProduct.getListRank()); assertEquals("1969-12-31T18:00:00Z", new ISO8601DateFormat().format(firstProduct.getActivationDate())); assertFalse(firstProduct.getPackage()); validateFeatures(firstProduct.getFeatures()); validateCostumerReviews(firstProduct.getCustomerReviews()); validateDetailImages(firstProduct.getDetailImages()); validateBrand(firstProduct.getBrand()); validateCategories(firstProduct.getCategories()); validateSkus(firstProduct.getSkus()); validateProductSummary(firstProduct.getSummary()); }
From source file:org.opencommercesearch.feed.SearchFeed.java
@Override public void doStartService() throws ServiceException { super.doStartService(); endpointUrl = getProductService().getUrl4Endpoint(Endpoint.PRODUCTS); mapper = new ObjectMapper().setDateFormat(new ISO8601DateFormat()) .setSerializationInclusion(JsonInclude.Include.NON_NULL); if (getWorkerCount() <= 0) { if (isLoggingInfo()) { logInfo("At least one worker is required to process the feed, setting number of workers to 1"); setWorkerCount(1);/*from ww w. jav a2 s . c o m*/ } } productTaskExecutor = Executors.newFixedThreadPool(getWorkerCount()); processedProductCount = new AtomicInteger(0); indexedProductCount = new AtomicInteger(0); failedProductCount = new AtomicInteger(0); sendTaskExecutor = Executors.newSingleThreadExecutor(); sendQueue = new LinkedBlockingDeque<SendQueueItem>(); }