Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date into Calendar? Howto?

 
wessel zaalberg
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
With:
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 );
Enjoy,
Manfred.
 
wessel zaalberg
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.
There is indeed a certain logic to it, although not obvious
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic