Skip to content

Commit

Permalink
add testcase for issue #1510
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 21, 2018
1 parent 75e1c25 commit a84154f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/com/alibaba/json/bvt/issue_1500/Issue1510.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.alibaba.json.bvt.issue_1500;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;

import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Issue1510 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}

public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"startTime\":\"2017-11-04\",\"endTime\":\"2017-11-14\"}", Model.class);
String text = JSON.toJSONString(model);
assertEquals("{\"endTime\":\"2017-11-14\",\"startTime\":\"2017-11-04\"}", text);
}

public static class Model {
@JSONField(format = "yyyy-MM-dd")
private Date startTime;

@JSONField(format = "yyyy-MM-dd")
private Date endTime;

public Date getStartTime() {
return startTime;
}

public void setStartTime(Date startTime) {
this.startTime = startTime;
}

public Date getEndTime() {
return endTime;
}

public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
}

0 comments on commit a84154f

Please sign in to comment.