File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Date into Calendar? Howto? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date into Calendar? Howto?" Watch "Date into Calendar? Howto?" New topic

Date into Calendar? Howto?

wessel zaalberg

Joined: Jul 27, 2001
Posts: 26
I have a query which returns date fields.
I also have a function that returns the number of days between two given Calendars. My problem is how to get the value of a date into a Calendar.
java.util.Date bdat = rs.getDate("bdat_ao");
bdat_ao = Calendar.getInstance();
bdat_ao.set(Calendar.YEAR, bdat.getYear());
I get the warning that bdat.getYear() is deprecated, which I knew but there doesnot seem to be any other way.
Does anybody knows a way around this?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Wessel,
Look into the java.util.Calendar class. It has superseded the Date stuff:
java.util.Date bdat = rs.getDate( "bdat_ao" );
Calendar cal = new Calendar();
cal.setTime( bdat );
wessel zaalberg

Joined: Jul 27, 2001
Posts: 26
There is indeed a certain logic to it, although not obvious
I agree. Here's the link:
subject: Date into Calendar? Howto?
jQuery in Action, 3rd edition