Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Re: Problem with Date


Message #1 by "Aaron Shettleroe" <jimslogan@y...> on Mon, 4 Feb 2002 00:46:11
Jean,
  If you use java.util.GregorianCalendar, it has an add() method to add or
subtract time to the current time stored in the object.  Below is a simple
program that adds 5 days to the current time as of when the program has run.

import java.util.GregorianCalendar;

public class TestDate
{
   public static void main(String[] args)
   {
      GregorianCalendar date = new GregorianCalendar();
      System.out.println(date.get(GregorianCalendar.DAY_OF_MONTH));
      date.add(GregorianCalendar.DAY_OF_MONTH, 5);
      System.out.println(date.get(GregorianCalendar.DAY_OF_MONTH));
   }
}

References:  Java SDK Documentation 1.3.1
             -java.util.GregorianCalendar

> hi all
>    can any one tell me how to add days to current date?
> 
> 
> regards
> 
> Jean 

  Return to Index