ya i looked in to this class too; But i am not able to get any clear idea about how should i proceed.
Please help me out.
You use the SimpleDateFormat class to take a String and convert it into a Date object. The Date object holds time information too, not just date information. Once you have your Date object, you can use the Calendar class to extract the time information out of it.
SCJP 6 || SCWCD 5
Joined: Oct 26, 2007
There is something missing in my requirement and your suggestions.
1. i am not aware of what format user enters to input time values. It can be like i said 9:30PM or 9:30 PM or 9:30 pm or 9:30pm or 9:30p.
2. i see SimpleDateFormat supports to fetch time formats from any input text. but not able to identify how to set variable format like i have given above.
3. Throwing exception is not my motive. I want to perceive what any user has given in the input. and i want it to be correctively perceived,
vijay shanker wrote:i am not aware of what format user enters to input time values.
As with any input you get from the user, you should (1) clean it so that it matches the format you're looking for, (2) force the user to input it in a specific way, or (3) use a combination of both. Maybe something like this: