| Author |
Date in Java
|
Jay Ashar
Ranch Hand
Joined: Oct 13, 2002
Posts: 208
|
|
In my java class I get a date from database and I am then formatting it using this code SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMddhhmm"); String duedate = formatter.format(duedate); so now I have something like 200311211130. I need to add 6 hours to this date, How can I do this? How can you add few hours of time to date?
|
SCJP 1.4<br />SCWCD 1.3
|
 |
Stephen Huey
Ranch Hand
Joined: Jul 15, 2003
Posts: 618
|
|
First of all, most of the Date class has been deprecated. So, read up on the Calendar class and a concrete subclass called GregorianCalendar. There's plenty of example code and documentation for what you want to do. If you ever need to mess with databases and dates, then look at java.sql.Date. Have fun!
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
First of all, most of the Date class has been deprecated. Quite a few of the methods have been deprecated, but the remaining methods work just fine - and in this case, they're all you need: [ November 21, 2003: Message edited by: Jim Yingst ]
|
"I'm not back." - Bill Harding, Twister
|
 |
Jay Ashar
Ranch Hand
Joined: Oct 13, 2002
Posts: 208
|
|
Jim, Looks like this method which you gave me would do whatever I need to do for now. Its very helpful. Thanks a lot guys, both of you. Hetal.
|
 |
 |
|
|
subject: Date in Java
|
|
|