List of usage examples for com.fasterxml.jackson.databind.util StdDateFormat StdDateFormat
public StdDateFormat()
From source file:com.spotify.docker.client.DockerDateFormatTest.java
@Before public void setUp() throws Exception { expected = new StdDateFormat().parse(millisecondDateString); }
From source file:org.jmingo.mapping.convert.mongo.type.deserialize.MongoDateDeserializer.java
/** * {@inheritDoc}/*w w w .j av a 2 s .c om*/ */ @Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode tree = jp.readValueAsTree(); if (tree.isPojo()) { POJONode pojoNode = (POJONode) tree; Object pojo = pojoNode.getPojo(); if (pojo instanceof Date) { return (Date) pojoNode.getPojo(); } else { throw new RuntimeException("unsupported date type, expected: " + Date.class.getName()); } } String stringDate = tree.asText(); StdDateFormat stdDateFormat = new StdDateFormat(); try { return stdDateFormat.parse(stringDate); } catch (ParseException e) { throw Throwables.propagate(e); } }
From source file:am.ik.categolj3.api.CategoLJ3ApiConfig.java
@Bean
@ConditionalOnMissingBean
ObjectMapper objectMapper() {
return new Jackson2ObjectMapperBuilder().dateFormat(new StdDateFormat()).build();
}
From source file:am.ik.categolj3.api.entry.EntryRestControllerDocumentation.java
@Before public void before() throws Exception { EntryProperties properties = new EntryProperties(); this.entryService = mock(EntryService.class); EntryRestController entryRestController = new EntryRestController(); entryRestController.entryProperties = properties; entryRestController.entryService = entryService; ObjectMapper objectMapper = new Jackson2ObjectMapperBuilder().dateFormat(new StdDateFormat()) .indentOutput(true).build(); MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter( objectMapper);// www .jav a2 s.com this.mockMvc = MockMvcBuilders.standaloneSetup(entryRestController) .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver()) .setMessageConverters(jackson2HttpMessageConverter) .apply(documentationConfiguration(this.restDocumentation)).build(); }
From source file:org.craftercms.profile.utils.AccessTokenManagerCliTest.java
@Test public void testList() throws Exception { tokens.add(createTestToken());/* w ww.j ava 2 s .c o m*/ StringWriter outputWriter = new StringWriter(); BufferedReader stdIn = new BufferedReader(new StringReader("")); PrintWriter stdOut = new PrintWriter(outputWriter); AccessTokenManagerCli cli = new AccessTokenManagerCli(stdIn, stdOut, tokenRepository, objectMapper); cli.run("-list"); assertEquals("[{\"application\":\"crafterengine\",\"tenantPermissions\":[{\"allowedActions\":[" + "\"DELETE_TENANT\",\"UPDATE_TENANT\",\"MANAGE_TICKETS\",\"CREATE_TENANT\",\"READ_TENANT\"," + "\"MANAGE_PROFILES\"],\"tenant\":\"corporate\"}],\"expiresOn\":\"" + new StdDateFormat().format(new SimpleDateFormat(DATE_FORMAT).parse(EXPIRES_ON)) + "\",\"id\":" + "\"795b69f0-c044-11e3-8a33-0800200c9a66\"}]", outputWriter.toString().trim()); }
From source file:com.googlecode.jsonschema2pojo.rules.DefaultRule.java
private long parseDateToMillisecs(String valueAsText) { try {/*from w w w . jav a 2s . c o m*/ return Long.parseLong(valueAsText); } catch (NumberFormatException nfe) { try { return new StdDateFormat().parse(valueAsText).getTime(); } catch (ParseException pe) { throw new IllegalArgumentException("Unable to parse this string as a date: " + valueAsText); } } }
From source file:test.java.com.spotify.docker.client.DefaultDockerClientTest.java
@Test public void testDockerDateFormat() throws Exception { // This is the created date for busybox converted from nanoseconds to milliseconds final Date expected = new StdDateFormat().parse("2015-09-18T17:44:28.145Z"); final DockerDateFormat dateFormat = new DockerDateFormat(); // Verify DockerDateFormat handles millisecond precision correctly final Date milli = dateFormat.parse("2015-09-18T17:44:28.145Z"); assertThat(milli, equalTo(expected)); // Verify DockerDateFormat converts nanosecond precision down to millisecond precision final Date nano = dateFormat.parse("2015-09-18T17:44:28.145855389Z"); assertThat(nano, equalTo(expected)); // Verify the formatter works when used with the client sut.pull(BUSYBOX_BUILDROOT_2013_08_1); final ImageInfo imageInfo = sut.inspectImage(BUSYBOX_BUILDROOT_2013_08_1); assertThat(imageInfo.created(), equalTo(expected)); }