I'm trying to convert a JSON object to a date and write it to a database. The code to convert the date to EST
isn't working however. What's the best way to convert a date to EST
?
JSON entry
"custom_date_1": "2019-05-19","
Conversion Code
int id;
Date trainingDate;
SimpleDateFormat format = new SimpleDateFormat("DD-MM-YY", Locale.US);
TimeZone tz = TimeZone.getTimeZone("EST");
format.setTimeZone(tz);
logger.info("custom_date_1: {}", object.getString("custom_date_1"));
try {
id= Integer.parseInt(object.getString("employee_number"));
trainingDate = format.parse(object.getString("custom_date_1"));
//Still says GMT
logger.info("trainingDate: {}", trainingDate);
map.put("employee_number", id);
map.put("custom_date_1", trainingDate);
} catch (ParseException e) {
e.printStackTrace();
}
Log Statement
2019-06-10 14:00:00,226 INFO custom_date_1: 2019-05-19
2019-06-10 14:00:00,226 INFO trainingDate: Sun Dec 30 05:00:00 GMT 2018