Skip to content

Commit 86c7a06

Browse files
committed
changes to not use final variables
1 parent 014b744 commit 86c7a06

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

kiteconnect/src/com/zerodhatech/kiteconnect/KiteConnect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ public class KiteConnect {
3939
private String userId;
4040
private Gson gson;
4141

42-
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
43-
4442
/** Initializes KiteSDK with the api key provided for your app.
4543
* @param apiKey is the api key provided after creating new Kite Connect app on developers console.
4644
*/
@@ -52,6 +50,7 @@ public KiteConnect(String apiKey){
5250
@Override
5351
public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
5452
try {
53+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
5554
return format.parse(jsonElement.getAsString());
5655
} catch (ParseException e) {
5756
return null;
@@ -597,6 +596,7 @@ public TriggerRange getTriggerRange(String exchange, String tradingSymbol, Strin
597596
* @throws IOException is thrown when there is connection related error.
598597
* */
599598
public HistoricalData getHistoricalData(Date from, Date to, String token, String interval, boolean continuous) throws KiteException, IOException {
599+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
600600
Map<String, Object> params = new HashMap<>();
601601
params.put("from", format.format(from));
602602
params.put("to", format.format(to));

kiteconnect/src/com/zerodhatech/models/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public class User {
5050
* @return User is the parsed data.
5151
* */
5252
public User parseResponse(JSONObject response) throws JSONException {
53-
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
5453
GsonBuilder gsonBuilder = new GsonBuilder();
5554
gsonBuilder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
5655

5756
@Override
5857
public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
5958
try {
59+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
6060
return format.parse(jsonElement.getAsString());
6161
} catch (ParseException e) {
6262
return null;

kiteconnect/src/com/zerodhatech/ticker/KiteTicker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,13 @@ private void parseTextMessage(String message) {
696696
}
697697

698698
public Order getOrder(JSONObject data) {
699-
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
700699
GsonBuilder gsonBuilder = new GsonBuilder();
701700
gsonBuilder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
702701

703702
@Override
704703
public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
705704
try {
705+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
706706
return format.parse(jsonElement.getAsString());
707707
} catch (ParseException e) {
708708
return null;

0 commit comments

Comments
 (0)