use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DateParserTest method test_date_1.
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
java.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DateParserTest method test_date_new.
public void test_date_new() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = parser.parseObject(java.util.Date.class);
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DateParserTest method test_date_new_1.
public void test_date_new_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");
java.util.Date date = (java.util.Date) parser.parse();
Assert.assertEquals(new java.util.Date(1294552193254L), date);
parser.close();
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DateParserTest_sql_timestamp method test_date_4.
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294502400000L), date);
parser.close();
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DateParserTest_sql_timestamp method test_date_2.
public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294552193254L), date);
parser.close();
}
Aggregations