How to convert GMT datetime SQL data type to JAVA EST timestamp on JDK 1.7

Eric Hartojo :

datetime datatype in GMT SQL server: Column name = PostedDateTime Value = 2019-09-30 17:46:04.600

I'm trying to use JAVA code to convert that datetime value to an EST timestamp So the output should be: 2019-09-30 13:46:04

Any ideas how to convert this, please include the package that needs to be imported?

So far I have this:

SimpleDateFormat dr = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
SimpleDateFormat dr1 = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
String dateString = obj.getStringProperty("S_DISCUSSION_POSTEDDATETIME");
Date date = dr.parse(dateString);           
strRetBuffer.append(obj.getStringProperty("S_DISCUSSION_AUTHOR") + ": " + dr1.format(date) + ": " + obj.getStringProperty("S_DISCUSSION_TOPICNAME")+": " +obj.getStringProperty("S_DISCUSSION_BODY") + "\n\r" );
Eric Hartojo :
        String x = "2019-09-30 17:46:04.600";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date date = formatter.parse(x);
        System.out.println(date);
        System.out.println(formatter.format(date));
        outputFormat.setTimeZone(TimeZone.getTimeZone("America/New_York"));
        System.out.println(outputFormat.format(date));

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=307340&siteId=1