diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-04 18:01:43 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-04 18:01:43 +0500 |
commit | 87392d9fbb0289b5486496b6e6b97db1ea84e2b7 (patch) | |
tree | 6d8413ad76307ee7bc52b5788dc202bb55762958 /src/org/traccar/protocol/Pt502ProtocolEncoder.java | |
parent | 99fd421c76c8e7491095a91630516f6d2db27034 (diff) | |
download | trackermap-server-87392d9fbb0289b5486496b6e6b97db1ea84e2b7.tar.gz trackermap-server-87392d9fbb0289b5486496b6e6b97db1ea84e2b7.tar.bz2 trackermap-server-87392d9fbb0289b5486496b6e6b97db1ea84e2b7.zip |
Accept timezone id instead of offset in commands
Diffstat (limited to 'src/org/traccar/protocol/Pt502ProtocolEncoder.java')
-rw-r--r-- | src/org/traccar/protocol/Pt502ProtocolEncoder.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Pt502ProtocolEncoder.java b/src/org/traccar/protocol/Pt502ProtocolEncoder.java index 5f7665e50..d5e219bd2 100644 --- a/src/org/traccar/protocol/Pt502ProtocolEncoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,27 @@ */ package org.traccar.protocol; +import java.util.TimeZone; + import org.traccar.StringProtocolEncoder; import org.traccar.helper.Log; import org.traccar.model.Command; -public class Pt502ProtocolEncoder extends StringProtocolEncoder { +public class Pt502ProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter { + + @Override + public String formatValue(String key, Object value) { + if (key.equals(Command.KEY_TIMEZONE)) { + return String.valueOf(TimeZone.getTimeZone(value.toString()).getRawOffset() / 3600000); + } + + return null; + } + + @Override + protected String formatCommand(Command command, String format, String... keys) { + return super.formatCommand(command, format, this, keys); + } @Override protected Object encodeCommand(Command command) { |