Solved

Problem parsing a time pattern (HH is sometimes H)

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
immutable object concept 5 119
dateFashion java challenge 9 138
grep code 4 183
Suggestion on WebSite Template Sites 6 101
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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