时间格式的时间 转json的时候变成正常的string时间20170519

public class JsonDateValueProcessor implements JsonValueProcessor {    private String format ="yyyyMMdd";

public JsonDateValueProcessor() {        super();    }

public JsonDateValueProcessor(String format) {        super();        this.format = format;    }

@Override    public Object processArrayValue(Object paramObject,                                    JsonConfig paramJsonConfig) {        return process(paramObject);    }

@Override    public Object processObjectValue(String paramString, Object paramObject,                                     JsonConfig paramJsonConfig) {        return process(paramObject);    }

private Object process(Object value){        if(value instanceof Date){            SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);            return sdf.format(value);        }        return value == null ? "" : value.toString();    }}

controller里这样写
List<T> list = service.queryFromWtxs();   //查询到要显示的实体类表JsonConfig jsonConfig = new JsonConfig();jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());JSONArray jsonArray22=JSONArray.fromObject(list,jsonConfig);        //实体类表转成json;时间变转换器里的时间格式sum = list.size();mv.addObject("list",jsonArray22);        //在jsp使用“list”
时间: 2024-08-08 13:44:34

时间格式的时间 转json的时候变成正常的string时间20170519的相关文章

Python中time模块和datetime模块的常用操作以及几种常用时间格式间的转换

最常见以及常用的几种时间格式 1.时间戳(timestamp),时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. 2.时间元组(struct_time),共有九个元素组. 3.格式化时间(format time ),可以格式化为固定或者自定义格式,增加可读性. #!/usr/bin/env python # -*- coding:utf-8 -*- import time #时间戳格式,默认获取当前时间 1500029143.7640195 timestamp = tim

IIS时间格式设置

IIS时间格式调整: (已解决)今天在用IIS7的时候发现一个关于时间格式的问题,当我在ASP中使用now()时间函数的时候,日期是以"/"来分隔,而不是以"-"来分隔的,使得我在运行程序的时候老出错,后来经过研究终于找到解方法. 这里我使用的操作系统是Winodws Vista Ultimate Service Pack 1,在ASP中使用now()时间函数出现的结果如下: 2009/3/17 8:11:51 而我想要的结果是2009-3-17 8:11:51,不

【Hibernate】--时间格式处理

上篇介绍了使用Hibernate来实现简单的数据插入,在这个过程中,我们需要注意的一个地方就是时间格式问题.之前在做SSH网上商城.DRP时也遇到过类似的问题,下面时间格式的转换做一个小总结. 在进行插入时间格式数据时,视频实例中直接使用的New Date()方式获取当前时间.但是自己在demo运行过程中,提示时间格式存在问题,将该时间格式打印出来,发现使用的格式如下: Tue Aug 23 21:59:41 CST 2016 在网上商城部分遇到该问题,解决办法是将所有的datetime类型数据

java校验时间格式 HH:MM

package com; import java.text.SimpleDateFormat; import java.util.Date; /** * @author Gerrard */ public class CheckTimeHHMM { public static void main(String[] args) { boolean flg = checkTime("8:00"); boolean flg3 = checkTime("24:00"); b

linux时间戳和时间格式的转化

1.将时间戳转化为yyyy-MM-dd HH:mm:ss时间格式 date -d @时间戳(秒) 2.设置服务器时间---特别注意使用 date -s 时间

Thymeleaf模板格式化LocalDatetime时间格式

添加maven依赖 <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-java8time</artifactId> <version>3.0.1.RELEASE</version> </dependency> 前端模板上的写法: <span th:text="${#dates.for

29-jsp中用js进行时间格式转化

CST可以为如下4个不同的时区的缩写: 美国中部时间:Central Standard Time (USA) UT-6:00 澳大利亚中部时间:Central Standard Time (Australia) UT+9:30 中国标准时间:China Standard Time UT+8:00 古巴标准时间:Cuba Standard Time UT-4:00 GMT 世界时UT [1]  即格林尼治 [1]  平太阳时间,是指格林尼治所在地的标准时间,也是表示地球自转速率的一种形式 GMT指

将json的时间格式转换成正常的时间格式

/** * 对Date的扩展,将 Date 转化为指定格式的String * 月(M).日(d).12小时(h).24小时(H).分(m).秒(s).周(E).季度(q) 可以用 1-2 个占位符 * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) * eg: * (new Date()).pattern("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 * (new Date())

Newtonsoft.Json 序列化和反序列化 时间格式【转】

1.JSON序列化 string JsonStr= JsonConvert.SerializeObject(Entity); eg: A a=new A(); a.Name="Elain00"; a.Hobby="eat eat"; string jsonStr=JsonConvert.SerializeObject(a); 2.JSON反序列化 string jsonstr = "jsonString";Class model = JsonCo