forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateTest.java
More file actions
executable file
·28 lines (20 loc) · 1006 Bytes
/
Copy pathDateTest.java
File metadata and controls
executable file
·28 lines (20 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.alibaba.json.bvt;
import java.util.Date;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class DateTest extends TestCase {
public void test_date() throws Exception {
long millis = 1324138987429L;
Date date = new Date(millis);
Assert.assertEquals("1324138987429", JSON.toJSONString(date));
Assert.assertEquals("\"2011-12-18 00:23:07\"",
JSON.toJSONString(date, SerializerFeature.WriteDateUseDateFormat));
Assert.assertEquals("\"2011-12-18 00:23:07.429\"",
JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd HH:mm:ss.SSS"));
Assert.assertEquals("'2011-12-18 00:23:07.429'",
JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd HH:mm:ss.SSS",
SerializerFeature.UseSingleQuotes));
}
}