/** * Writes an encrypted workspace definition as a JSON string to the specified Writer object. * * @param workspace the Workspace object to write * @param writer the Writer object to write the workspace to * @throws WorkspaceWriterException if something goes wrong */ public void write(EncryptedWorkspace workspace, Writer writer) throws WorkspaceWriterException { if (workspace == null) { throw new IllegalArgumentException("EncryptedWorkspace cannot be null."); } if (writer == null) { throw new IllegalArgumentException("Writer cannot be null."); } try { ObjectMapper objectMapper = new ObjectMapper(); if (indentOutput) { objectMapper.enable(SerializationFeature.INDENT_OUTPUT); } objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); writer.write(objectMapper.writeValueAsString(workspace)); } catch (Exception e) { throw new WorkspaceWriterException("Could not write as JSON", e); } }
public static Date getStashCreationTimeStamp(String stashStartTime) throws ParseException { return new ISO8601DateFormat().parse(stashStartTime); }
public static DateFormat newUtcFormatter() { TimeZone tz = TimeZone.getTimeZone("UTC"); ISO8601DateFormat df = new ISO8601DateFormat(); df.setTimeZone(tz); return df; } }
@Override public Object getVariableValue(RestVariable result) { if (result.getValue() != null) { if (!(result.getValue() instanceof String)) { throw new FlowableIllegalArgumentException("Converter can only convert string to date"); } try { return isoFormatter.parse((String) result.getValue()); } catch (ParseException e) { throw new FlowableIllegalArgumentException("The given variable value is not a date: '" + result.getValue() + "'", e); } } return null; }
@Override public void convertVariableValue(Object variableValue, RestVariable result) { if (variableValue != null) { if (!(variableValue instanceof Date)) { throw new ActivitiIllegalArgumentException("Converter can only convert booleans"); } result.setValue(isoFormatter.format(variableValue)); } else { result.setValue(null); } }
@Override public Object getVariableValue(EngineRestVariable result) { if (result.getValue() != null) { if (!(result.getValue() instanceof String)) { throw new FlowableIllegalArgumentException("Converter can only convert string to date"); } try { return isoFormatter.parse((String) result.getValue()); } catch (ParseException e) { throw new FlowableIllegalArgumentException("The given variable value is not a date: '" + result.getValue() + "'", e); } } return null; }
@Override public void convertVariableValue(Object variableValue, EngineRestVariable result) { if (variableValue != null) { if (!(variableValue instanceof Date)) { throw new FlowableIllegalArgumentException("Converter can only convert booleans"); } result.setValue(isoFormatter.format(variableValue)); } else { result.setValue(null); } }
/** * Writes a workspace definition as a JSON string to the specified Writer object. * * @param workspace the Workspace object to write * @param writer the Writer object to write the workspace to * @throws WorkspaceWriterException if something goes wrong */ public void write(Workspace workspace, Writer writer) throws WorkspaceWriterException { if (workspace == null) { throw new IllegalArgumentException("Workspace cannot be null."); } if (writer == null) { throw new IllegalArgumentException("Writer cannot be null."); } try { ObjectMapper objectMapper = new ObjectMapper(); if (indentOutput) { objectMapper.enable(SerializationFeature.INDENT_OUTPUT); } objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); writer.write(objectMapper.writeValueAsString(workspace)); } catch (IOException ioe) { throw new WorkspaceWriterException("Could not write as JSON", ioe); } }
public static Date getStashCreationTimeStamp(String stashStartTime) throws ParseException { return new ISO8601DateFormat().parse(stashStartTime); }
private ObjectWriter createObjectWriter() { final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(Include.NON_EMPTY); final ISO8601DateFormat df = new ISO8601DateFormat(); df.setTimeZone(TimeZone.getTimeZone("UTC")); objectMapper.setDateFormat(df); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); return objectMapper.writer(); } }
@Override public Object getVariableValue(RestVariable result) { if (result.getValue() != null) { if (!(result.getValue() instanceof String)) { throw new ActivitiIllegalArgumentException("Converter can only convert string to date"); } try { return isoFormatter.parse((String) result.getValue()); } catch (ParseException e) { throw new ActivitiIllegalArgumentException("The given variable value is not a date: '" + result.getValue() + "'", e); } } return null; }
@Override public void convertVariableValue(Object variableValue, RestVariable result) { if (variableValue != null) { if (!(variableValue instanceof Date)) { throw new FlowableIllegalArgumentException("Converter can only convert booleans"); } result.setValue(isoFormatter.format(variableValue)); } else { result.setValue(null); } }
/** * Builde default Jackson ObjectMapper */ public static ObjectMapper build() { ObjectMapper mapper = new ObjectMapper(); mapper.setDateFormat(new ISO8601DateFormat()); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; } }
public static Date parse(String dateString) { try { return new ISO8601DateFormat().parse(dateString); } catch (ParseException e) { return throwUnchecked(e, Date.class); } }
super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule =
public static ObjectMapper createMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; }
@Override public Object apply(String context, Options options) throws IOException { String format = options.hash("format", null); try { return format == null ? new ISO8601DateFormat().parse(context) : new SimpleDateFormat(format).parse(context); } catch (ParseException e) { return Exceptions.throwUnchecked(e, Object.class); } } }
super.registerModule(new JaxbAnnotationModule()); configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); ISO8601DateFormat dateFormat = new ISO8601DateFormat(); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); setDateFormat(dateFormat); SimpleModule deserializerModule =
@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; }
public static Date toDate(QueryParameter parameter) { try { return parameter.isPresent() ? new ISO8601DateFormat().parse(parameter.firstValue()) : null; } catch (ParseException e) { throw new IllegalArgumentException(parameter.firstValue() + " is not a valid ISO8601 date"); } } }