Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

asked on

compare datetime

I need to do a datetime comparison that takes a string argument such as 9:00 AM and compares it to the current datetime on the server.  

So, if I wanted to compare 3/20/2012 9:00 AM > 3/20/2010 1:00PM it should be false because 9:00 AM is less than 1:00 PM.

One other issue is the time on the server is GMT and I need to translate that time into Mountain time (Phoenix, Arizona).

I'm posting in the java forum, but I'm writing this code in Apex (Salesforce language), which is a derivative of the Java language and is compiled on a Java App Server.  One issue is Apex does not have the Java class library available, so I have to write this from scratch.

Any help is appreciated.
Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Stuber
Sean Stuber

to convert a string to a date try something like this...


Datetime dt = DateTime.parse('3/20/2012 9:00 AM');
Java has a lot of functionality associated with dates - if none of it is avaialable in Apex, it is not clear how you can do it