function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Java datetime to SFDC datetime field need help

Hi guys i can't seem to get the hours and minutes to show in a datetime field in SFDC coming from an update from a java client app


        SimpleDateFormat timeStamp = new SimpleDateFormat("yyyy-MM-dd\'T\'HH:mm:ss");
        try {
            runRequest.setValue("Requested_Date__c", timeStamp.parse(timeStamp.format(new Date())));
        } catch (ParseException e) {
            System.out.println("Requested_Date__c Error : " + e.getCause());


it updates the date time field but it never shows the hhmmss??


Your SimpleDateFormat is a bit wrong.


private static SimpleDateFormat sfdcDateTimeParser = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");


ok i changed the format but it is still not showing the hours and seconds it is always 0:00


I am not sure if this is right?


SimpleDateFormat timeStamp = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");

runRequest.setValue("Requested_Date__c", timeStamp.parse(timeStamp.format(new Date())));



Your best bet is to use joda time.


Date/Datetime libraries in Java are fairly week and inconsistent, especially when dealing with multiple timezones and proper conversion of data. Jodatime fixes almost all of the issues I have with the standard java libraries and joda ins in consideration to be the standard date/datime libraries for the next version of Java.