• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date validation

 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic