-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1510.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |