mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Fix thread-safety issue in DateSerializer.
This commit is contained in:
parent
1216a009cb
commit
b729e450ab
1 changed files with 1 additions and 1 deletions
|
@ -8,7 +8,6 @@ import java.util.GregorianCalendar;
|
|||
class DateSerializer implements Serializer {
|
||||
static final Serializer DATE_SERIALIZER = new DateSerializer();
|
||||
private static final Calendar calendar = new GregorianCalendar();
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:m:ss");
|
||||
|
||||
@Override
|
||||
public boolean canSerialize(Object value) {
|
||||
|
@ -17,6 +16,7 @@ class DateSerializer implements Serializer {
|
|||
|
||||
@Override
|
||||
public void serialize(Object value, SerializerContext context) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:m:ss");
|
||||
context.serialized.append(dateFormat.format(value));
|
||||
int tzOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / (60 * 1000);
|
||||
context.serialized.append(String.format("%+03d:%02d", tzOffset / 60, tzOffset % 60));
|
||||
|
|
Loading…
Reference in a new issue