• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Date" Problem

 
Paresh Joshi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting Date object from another Class's method.
now i want to add some days (integer) and wants new Date (only date part)

there are some methods in this class but most of them are Deprecated

is there any way to do this ? , or any way to convert Date object to Calendar

please help !

Thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class Calendar has a setTime() method which you can use to set the calendar to the date and time of a Date object:
 
Hong Lu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see below

Calendar calendar = Calendar.getInstance();
calendar.setTime(yourDate);

you may find more useful information in API document.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic