Solved

Problem parsing a time pattern (HH is sometimes H)

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript onclick event 4 107
Retrieving file from bytes array in spring mvc 8 56
how to hide hide popup page refresh second time? 10 110
listing all functions in JavaScript 19 173
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 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

19 Experts available now in Live!

Get 1:1 Help Now