Commit 4f02ba33 authored by 高铁's avatar 高铁
Browse files

bug fixed for Timestamp serialize

parent 8276a40a
Showing with 9 additions and 8 deletions
+9 -8
......@@ -156,7 +156,7 @@ public class DateCodec extends AbstractDateDeserializer implements ObjectSeriali
if (nanos > 0) {
buf = "0000-00-00 00:00:00.000000000".toCharArray();
int nanoSize = IOUtils.stringSize(nanos);
IOUtils.getChars(nanos, 30 - (9 - nanoSize), buf);
IOUtils.getChars(nanos, 29 - (9 - nanoSize), buf);
IOUtils.getChars(second, 19, buf);
IOUtils.getChars(minute, 16, buf);
IOUtils.getChars(hour, 13, buf);
......
package com.alibaba.json.bvt.issue_3000;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.sql.Timestamp;
import java.util.Calendar;
public class Issue3093 extends TestCase {
public void test_for_issue() throws Exception {
String jsonStr = "{1:1}";
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
assertTrue(jsonObject.containsKey(1));
assertTrue(jsonObject.containsKey("1"));
assertEquals(1, jsonObject.get(1));
assertEquals(1, jsonObject.get("1"));
Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment