File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date validation" Watch "Date validation" New topic
Author

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
"hh:mm:ss".
Any help regarding this will be useful
Thanks
Ramya
Ulf Dittmer
Marshal

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

System.out.println(myDateFormat.format(myTime));
[ October 24, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
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
Bartender

Joined: Aug 20, 2001
Posts: 1817

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: http://aspose.com/file-tools
 
subject: Date validation