How to print time in 12h am/pm format?

I am trying to print a datestamp in an Excel Jaspersoft report with the time in 12-hour am/pm format. Under 'Dataset and Query', the database field (which is date format) has Class Type = java.sql.Date:

In the table, under Text Properties, I am using the format 'MM/dd/yy hh:mm a', which is supposed to give me what I want:

However, in the report, the timestamps are listed with military (24hr) time:

What am I doing wrong? I should mention that I'm defining them as dates rather than strings so the user can sort them by date in the Excel file. Thanks in advance for any help - and please give specific instructions because I am not an expert at Jaspersoft Report!

p.s. I am referring to this pattern guide: https://community.jaspersoft.com/wiki/date-and-time-patterns

selene.platt_1's picture
Joined: Dec 30 2021 - 9:52am
Last seen: 3 months 1 week ago

2 Answers:

The proper format is  MM/dd/yy h:mm a

the two hh gives you the 24 hr clock.

sanderse's picture
3677
Joined: Jul 31 2017 - 3:51pm
Last seen: 2 weeks 1 day ago

Thanks, I had just assumed that two m's meant a 2-digit hour, e.g. 03:00.  Interestingly, in the Excel output report, the time still looks like it's 24-hr until I click on a cell - then it appears as 12-hr. When I changed the cell formatting from Custom to Date and specified the correct format, the dates all displayed as I expected. Really odd.

selene.platt_1's picture
Joined: Dec 30 2021 - 9:52am
Last seen: 3 months 1 week ago
Feedback
randomness