Java Code Examples for org.codehaus.jackson.map.ObjectMapper#setDateFormat()
The following examples show how to use
org.codehaus.jackson.map.ObjectMapper#setDateFormat() .
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: WriteJsonServletHandler.java From urule with Apache License 2.0 | 6 votes |
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{ resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setContentType("text/json"); resp.setCharacterEncoding("UTF-8"); ObjectMapper mapper=new ObjectMapper(); mapper.setSerializationInclusion(Inclusion.NON_NULL); mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false); mapper.setDateFormat(new SimpleDateFormat(Configure.getDateFormat())); OutputStream out = resp.getOutputStream(); try { mapper.writeValue(out, obj); } finally { out.flush(); out.close(); } }
Example 2
Source File: WriteJsonServletHandler.java From uflo with Apache License 2.0 | 6 votes |
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{ resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setContentType("text/json"); resp.setCharacterEncoding("UTF-8"); ObjectMapper mapper=new ObjectMapper(); mapper.setSerializationInclusion(Inclusion.NON_NULL); mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false); mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); OutputStream out = resp.getOutputStream(); try { mapper.writeValue(out, obj); } finally { out.flush(); out.close(); } }
Example 3
Source File: WriteJsonServletAction.java From ureport with Apache License 2.0 | 5 votes |
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{ resp.setContentType("text/json"); resp.setCharacterEncoding("UTF-8"); ObjectMapper mapper=new ObjectMapper(); mapper.setSerializationInclusion(Inclusion.NON_NULL); mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false); mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); OutputStream out = resp.getOutputStream(); try { mapper.writeValue(out, obj); } finally { out.flush(); out.close(); } }
Example 4
Source File: BulkV2Connection.java From components with Apache License 2.0 | 4 votes |
static String serializeToJson(Object value) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Inclusion.NON_NULL); mapper.setDateFormat(CalendarCodec.getDateFormat()); return mapper.writeValueAsString(value); }