You need to sign in to do that
Don't have an account?
lodoss1118
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'");
timeStamp.setTimeZone(TimeZone.getTimeZone("GMT"));
runRequest.setValue("Requested_Date__c", timeStamp.parse(timeStamp.format(new Date())));
Your best bet is to use joda time.
http://joda-time.sourceforge.net/
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.