Hi, I've been experimenting with a couple of classes from the java.util package, but I havent been able to solve my problem.
If I am given a date, and I want to return a date representing 90 days after the first of the next month, what should I do?
example : If I am given 13 March 2003, I must return a date exactly 90 days after the 1st April 2003
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar;
public class DateTest {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("MMM-dd-yyyy");
// March-13-2003
GregorianCalendar greg = new GregorianCalendar(2003,Calendar.MARCH,13);
System.out.println(sdf.format(greg.getTime()));
// Get to next month
greg.add(Calendar.MONTH,1);
// Set to first day
greg.set(Calendar.DAY_OF_MONTH,1);
// Should show Apr-1-2003
System.out.println(sdf.format(greg.getTime()));
// Add 90 days
greg.add(Calendar.DATE,90);
// Should show Jun-30-2003
System.out.println(sdf.format(greg.getTime()));
}
}
--
_________________________________________________________________________
"In theory, there is no difference between theory and practice. In practice, there is no relationship between theory and practice."
_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
