jackson2.8.4java对象序列化成json字符串格式化时间
public class User {
private int id;
private Date birthday;
private double money;
private String name;
public User() {
}
public User(int id, String name, Date birthday) {
super();
this.id = id;
this.name = name;
this.birthday = birthday;
}
public User(int id, String name, double money, Date birthday) {
super();
this.id = id;
this.name = name;
this.money = money;
this.birthday = birthday;}
public Date getBirthday() {
return birthday;
}
public int getId() {
return id;
}
public double getMoney() {
return money;
}
public String getName() {
return name;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public void setId(int id) {
this.id = id;
}
public void setMoney(double money) {
this.money = money;
}
public void setName(String name) {
this.name = name;
}
}
ObjectMapper mapper = new ObjectMapper();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
mapper.setDateFormat(format);
User user = new User(1,"JACK",new Date());
String outJson = mapper.writeValueAsString(user);
System.out.println(outJson);
结果{"id":1,"name":"JACK","money":0.0,"birthday":"2013-04-01"}
jackson2.8.4java对象序列化成json字符串格式化时间的更多相关文章
- C#将对象序列化成JSON字符串
C#将对象序列化成JSON字符串 public string GetJsonString() { List<Product> products = new List<Product& ...
- 对象序列化成Json字符串 及 反序列化成对象
一. public static string JsonSerializer<T>(T t) { DataContractJsonSerializer ...
- C#实体对象序列化成Json,格式化,并让字段的首字母小写
解决办法有两种:第一种:使用对象的字段属性设置JsonProperty来实现(不推荐,因为需要手动的修改每个字段的属性) public class UserInfo { [JsonProperty(& ...
- 使用 EntityFramework后把一个对象序列化成json字符串引起循环引用的问题
先看一个T4模板生成的model实体类 著作权归作者所有. 商业转载请联系作者获得授权,非商业转载请注明出处. 作者:卷猫 链接:http://anneke.cn/ArticleInfo/Detial ...
- SpringMVC将表单对象序列化成Json字符串提交,以List接收
出自:http://blog.csdn.net/m0_37595732/article/details/71440853 HTML <%@ page language="java&qu ...
- 将Java对象序列化成JSON和XML格式
1.先定义一个Java对象Person: public class Person { String name; int age; int number; public String getName() ...
- @JsonInclude注解,RestTemplate传输值为null的属性,利用FastJson将属性中有空值null的对象转化成Json字符串
一个pojo类: import lombok.Data; @Data public class Friend { private String name; private int age; priva ...
- .net 将List序列化成Json字符串
将List类型转化为Json,是我们平常开发时最常见的了.在使用中,有很多种方法,也可以使用. 第一种 第三方组件:Newtonsoft.Json.dll //转化成Json Newtonsoft.J ...
- .Net使用Newtonsoft.Json.dll(JSON.NET)对象序列化成json、反序列化json示例教程
JSON作为一种轻量级的数据交换格式,简单灵活,被很多系统用来数据交互,作为一名.NET开发人员,JSON.NET无疑是最好的序列化框架,支持XML和JSON序列化,高性能,免费开源,支持LINQ查询 ...
随机推荐
- vsftp限制FTP用户只能访问自己的目录
修改配置文件/etc/vsftpd/vsftpd.conf chroot_local_user=YESallow_writeable_chroot=YESchroot_list_enable=YESc ...
- 微信小程序独家秘笈之左滑删除
代码地址如下:http://www.demodashi.com/demo/14056.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- opencv-3.0.0-beta和opencv2版本号的差别
我的机器:64位系统 第一步: opencv官网下载opencv3.0.0-beta版本号.解压到自己的目录,我的目录是E:\,解压后在E盘出现名为opencv的目录.该目录下有两个子目录 第二步:配 ...
- idea搭建简易ssm项目
按照http://www.cnblogs.com/hackyo/p/6646051.html来搭建ssm框架,一步成功,特此记录一下. 本机环境: idea2017.3 jdk1.8 mysql5.5 ...
- C-常用字符串操作函数详解
//使用字符串操作应时刻注意字符串或者数组长度!!避免溢出!! 1. size_t strlen(char const *str); //计算字符串长度, 注意返回size_t类型的值, 即unsig ...
- HDUOJ----2647Reward
Reward Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- 【LeetCode】93. Restore IP Addresses
Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...
- configure: error: newly created file is older than distributed files!
在linux下安装软件包的时候,有时候提示 configure: error: newly created file is older than distributed files!Check you ...
- MVC中JSON字符长度超出限制
本文导读:在MVC中通过JsonResult返回JSON字符串时,如果字符串长度过长,会抛出使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错,字符串的长度超过了为 ...
- Interface_GL通过gl_interface导入日记账(案例)
2014-06-17 BaoXinjian