Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Fastjson
Commits
4f02ba33
Commit
4f02ba33
authored
5 years ago
by
高铁
Browse files
Options
Download
Email Patches
Plain Diff
bug fixed for Timestamp serialize
parent
8276a40a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/alibaba/fastjson/serializer/DateCodec.java
+1
-1
src/main/java/com/alibaba/fastjson/serializer/DateCodec.java
src/test/java/com/alibaba/json/bvt/issue_3000/Issue3093.java
+8
-7
src/test/java/com/alibaba/json/bvt/issue_3000/Issue3093.java
with
9 additions
and
8 deletions
+9
-8
src/main/java/com/alibaba/fastjson/serializer/DateCodec.java
+
1
-
1
View file @
4f02ba33
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/test/java/com/alibaba/json/bvt/issue_3000/Issue3093.java
+
8
-
7
View file @
4f02ba33
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
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment