List of usage examples for com.fasterxml.jackson.databind ObjectMapper setDateFormat
public ObjectMapper setDateFormat(DateFormat dateFormat)
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; }
From source file:org.apache.geode.pdx.internal.PdxInstanceImpl.java
private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setDateFormat(new SimpleDateFormat("MM/dd/yyyy")); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); return mapper; }
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:de.fau.cs.inf2.tree.evaluation.TreeEvalIO.java
public static ObjectMapper createJSONMapper(final DataFormat format) { final ObjectMapper mapper; {/*from w w w . j a v a2 s.c om*/ switch (format) { case FORMAT_JSON: { mapper = new ObjectMapper(); break; } default: { assert (false); return null; } } } // configure mapper { mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.setSerializationInclusion(Include.NON_NULL); DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S"); mapper.setDateFormat(df); addMixIns(mapper, TimeSummary.class, MixInTimeSummary.class); addMixIns(mapper, DiffSummary.class, MixInDiffSummary.class); addMixIns(mapper, TreeMatcherTypeEnum.class, MixInTreeMatcherTypeEnum.class); addMixIns(mapper, PsoResult.class, MixInPSOResult.class); addMixIns(mapper, ValidationDecision.class, MixInValidationDecision.class); addMixIns(mapper, ValidationDecisionList.class, MixInValidationDecisionList.class); addMixIns(mapper, ValidationEntry.class, MixInValidationEntry.class); addMixIns(mapper, ValidationEnum.class, MixInValidationEnum.class); addMixIns(mapper, ValidationRating.class, MixInValidationRating.class); addMixIns(mapper, ValidationInputSummary.class, MixInValidationInputSummary.class); addMixIns(mapper, ValidationInfo.class, MixInValidationInfo.class); } return mapper; }
From source file:com.nissatech.proasense.eventplayer.partnerconfigurations.HellaConfiguration.java
/** * {@inheritDoc}//from www . j a va 2s .c o 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.nissatech.proasense.eventplayer.partnerconfigurations.HellaConfiguration.java
/** * {@inheritDoc}/*from ww w. j a va 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:services.bizdockapi.BizdockApiClientImpl.java
/** * Initialize the service.//w ww . j ava 2s . c o m * * @param lifecycle * the Play life cycle service * @param configuration * the Play configuration service */ @Inject public BizdockApiClientImpl(ApplicationLifecycle lifecycle, Configuration configuration) { Logger.info("SERVICE>>> BizdockApiClientImpl starting..."); lifecycle.addStopHook(() -> { Logger.info("SERVICE>>> BizdockApiClientImpl stopping..."); Logger.info("SERVICE>>> BizdockApiClientImpl stopped"); return Promise.pure(null); }); ObjectMapper mapper = new ObjectMapper(); mapper.setDateFormat(new SimpleDateFormat(IApiConstants.DATE_FORMAT)); this.mapper = mapper; Logger.info("SERVICE>>> BizdockApiClientImpl started"); }
From source file:com.liato.bankdroid.banking.banks.icabanken.ICABanken.java
public Urllib login() throws LoginException, BankException { urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_icabanken)); urlopen.addHeader("ApiVersion", API_VERSION); urlopen.addHeader("Accept", "application/json"); urlopen.addHeader("ApiKey", API_KEY); urlopen.addHeader("ClientHardware", Build.MODEL); urlopen.addHeader("ClientOS", "Android"); urlopen.addHeader("ClientOSVersion", Integer.toString(Build.VERSION.SDK_INT)); urlopen.addHeader("ClientAppVersion", "777"); try {/* w w w . ja va 2s . co m*/ String response = urlopen.open( String.format("%s/login/passwordlogin?customerId=%s&password=%s", API_URL, username, password)); if (response == null || "".equals(response)) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } ObjectMapper vObjectMapper = new ObjectMapper(); vObjectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", new Locale("sv", "SE"))); LoginResponse loginResponse = vObjectMapper.readValue(response, LoginResponse.class); addAccounts(loginResponse.getAccountList()); } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } return urlopen; }
From source file:org.jrb.docasm.ApplicationConfig.java
@Bean public MappingJackson2HttpMessageConverter messageConverter() { // assemble json mapper final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.setDateFormat(DateFormat.getDateInstance()); objectMapper.configure(Feature.WRITE_NUMBERS_AS_STRINGS, true); // assemble json message converter final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); converter.setObjectMapper(objectMapper); return converter; }
From source file:com.hillert.botanic.MainApp.java
/** * Configure the Jackson {@link ObjectMapper}. Use the {@link ISO8601DateFormatWithMilliSeconds} * to set a custom {@link DateFormat} ensuring that JSON Data are serialized * using the {@code ISO8601} format.//w w w . j a v a 2 s. com */ @Bean @Primary public ObjectMapper objectMapper() { ObjectMapper objectMapper = super.objectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.setDateFormat(new ISO8601DateFormatWithMilliSeconds()); return objectMapper; }