From 6fa45d63da0bfe52a35ea84f6dc7b62dd508f195 Mon Sep 17 00:00:00 2001 From: qifanyang <584874132@qq.com> Date: Sun, 9 Aug 2015 17:30:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bug=5F376=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加bug_376测试 --- .../json/bvt/bug/Bug_376_for_iso8601.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/test/java/com/alibaba/json/bvt/bug/Bug_376_for_iso8601.java diff --git a/src/test/java/com/alibaba/json/bvt/bug/Bug_376_for_iso8601.java b/src/test/java/com/alibaba/json/bvt/bug/Bug_376_for_iso8601.java new file mode 100644 index 000000000..8714cbf7a --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/bug/Bug_376_for_iso8601.java @@ -0,0 +1,47 @@ +package com.alibaba.json.bvt.bug; + +import java.text.DateFormat; +import java.util.Date; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.parser.Feature; + +import junit.framework.TestCase; + +public class Bug_376_for_iso8601 extends TestCase { + + public void test_fix() { + + String s = "{date: \"2015-07-22T19:13:42Z\"}"; + String s2 = "{date: \"2015-07-22T19:13:42.000Z\"}"; + + MyObj o = JSON.parseObject(s, MyObj.class, Feature.AllowISO8601DateFormat); + MyObj o2 = JSON.parseObject(s2, MyObj.class, Feature.AllowISO8601DateFormat); + + System.out.println(DateFormat.getDateTimeInstance().format(o.getDate())); + System.out.println(DateFormat.getDateTimeInstance().format(o2.getDate())); + + //修复之前输出 + //2015-7-22 19:13:42 + //2015-7-23 3:13:42 + + //修复之后输出 + //2015-7-23 3:13:42 + //2015-7-23 3:13:42 + + + } + + static class MyObj { + private Date date; + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + } + +}