File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Jul 19, 2007
Aug 17, 2007 00:39:00
i am getting
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
is there any way to do this ? , or any way to convert
please help !
Jesper de Jong
Joined: Aug 16, 2005
Aug 17, 2007 00:47:00
Class Calendar has a setTime() method which you can use to set the calendar to the date and time of a Date object:
Date date = ...; Calendar cal = Calendar.getInstance(); cal.setTime(date); // Now you can do calculations, for example add 5 days cal.add(Calendar.DATE, 5); // Convert it back to a Date object Date result = cal.getTime();
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 8 API documentation
Joined: Aug 13, 2007
Aug 17, 2007 00:50:00
Calendar calendar = Calendar.getInstance();
you may find more useful information in API document.
It is sorta covered in the
JavaRanch Style Guide
subject: "Date" Problem
SimpleDateFormat parses illegal date string
JNI interacting with C++
Converting dates to GMT
Conversion of String to Date
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015