troubleshooting Question

Convert 'Long Date' to HL7 Date 'yyyyMMddhhmmss'

Avatar of sidwelle
sidwelleFlag for United States of America asked on
6 Comments1 Solution260 ViewsLast Modified:
I need to convert a 'Long Date' to HL7 date, and I was trying to do it with some of functions available and not appending each component of the date and time independently.
Input format: 'Mon May 21, 2018 11:52 PM'
Output format: 'yyyyMMddhhmmss'

      // example: Mon May 21, 2018 11:52 PM
      var d1 = new Date("Mon May 21, 2018 11:52 PM");    
      // var d = org.joda.time.format.DateTimeFormat.forPattern('MM/dd/yyyy').parseDateTime(ServDatetime);

      var dt = d1.toLocaleDateString() + " " + d1.toLocaleTimeString().replace(" CDT", "").replace(" PM", "");
      var d2 = org.joda.time.format.DateTimeFormat.forPattern('DDD MMM dd, yyyy hh:mm').parseDateTime(dt);    // This line fails !!, not sure how to set this up ??
      alert('New Date: ' + d2.toString());
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros