This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Date validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date validation" Watch "Date validation" New topic

Date validation

meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
Hi all.

I am trying to get the time format in hh:mm format.
Below is the code that i used for that.

i wanted to get the output in "hh:mm" format but i am getting in form of
Any help regarding this will be useful
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
You'll need to format it during output as well, something like

[ October 24, 2005: Message edited by: Ulf Dittmer ]
meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
hi that is not working.
Because the return type of format() is string ,but i want the return type to be Date object.So to convert the string to Date if i use parse then again the output is in hh:mm:ss format,but i wanted it to be in hh:mm format.
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

I'm a little confused. "Format" doesn't make sense for a Date object. Dates are only formatted when they become string representations of Dates. So the return type should be a String.

Perhaps what you want is to set the seconds of the date to zero? To do that, take a look at the Calendar class.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
I agree. Here's the link:
subject: Date validation
It's not a secret anymore!