Solved

Problem parsing a time pattern (HH is sometimes H)

Posted on 2006-10-25
5
241 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set up Wildfly 10 8 444
'exit' is not valid keyword in java 14 163
maven set up 2 187
maven disable workspace resolution 1 37
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Read our guide on how to survive being on-call.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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