[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem parsing a time pattern (HH is sometimes H)

Posted on 2006-10-25
5
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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