How to frame Date to get this Format 3/24/16 2:36:46 PM

Hi Everyone, Im trying to achieve this format 3/24/16 2:36:46 PM in Jasper , Could you help me out in Framing the Date Functions to achieve this.

Regards,

Santosh
 

santosh.audi19's picture
Joined: Sep 9 2015 - 9:58am
Last seen: 2 years 6 months ago

2 Answers:

Hi Everone, I had a Try and this is working
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss a").format(new Date())

 

santosh.audi19's picture
Joined: Sep 9 2015 - 9:58am
Last seen: 2 years 6 months ago

That's very strange. Your Java has a but because "yyyy" would return "24-03-2016" instead of "3/24/16"!

What you want is 

new SimpleDateFormat("M/dd/yy HH:mm:ss a").format(new Date())

 

Anyways, the proper way to do this in JasperReports is to set expression to "new Date()" and set pattern to "M/dd/yy HH:mm:ss a"

hozawa's picture
190547
Joined: Apr 24 2010 - 4:31pm
Last seen: 4 years 3 months ago
Feedback
randomness