Solved

Problem parsing a time pattern (HH is sometimes H)

Posted on 2006-10-25
5
237 Views
Last Modified: 2006-11-18
I'm having a problem parsing a time pattern. I'm using:
<fmt:parseDate var="parsedTime" pattern="HHmmss" value="${data.Header.entered_time}" />
but the problem is, the application sending me the data is using military time but it is sending me only a single digit hour for the morning hours (e.g. 9am is 9 not 09). Is there a "wild card" I can use to test if the hour is 1 digit? If not, can someone help me on how to capture/modify the hour to 2 digits instead of one?

Thanks,
biglarrrr
0
Comment
Question by:biglarrrr
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:jaggernat
ID: 17807330
0
 

Author Comment

by:biglarrrr
ID: 17807500
Thanks. I actually read that one before I made my post. The problem with that one is it's only talking about the date (day, month, year) not the time. Here are 2 examples of what I'm getting back from our app...

809 (08:09)
1345 (13:45)

1345 is fine but when it tries to parse 809 it failes because 809 isn't a valid time for a pattern of HHmmss.

Thanks,
biglarrrr
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 500 total points
ID: 17808417
As far as I know,

Java does not have the "wild card" I can use to test if the hour is 1 digit or 2 digit automatically. What you can do is to check the length of the string itself.

For example,
809 - the length is 3 so you need to append "0" on the front. If the length is 4 then leave it.
0
 

Author Comment

by:biglarrrr
ID: 17809084
Well, it wasn't the cleanest way to do this but checking the length worked. :) Thanks for the help!

Thanks,
biglarrrr
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17809088
;)

Glad I could help
David
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now