Results 1 to 2 of 2
  1. #1
    newnewgen is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default date is not working properly

    Following is the code for adding date

    public boolean addDate(int iDate)
    {

    Calendar cal = Calendar.getInstance();

    cal.set(2009,02,01);
    cal.add(Calendar.DATE, iDate); // Add days in Dates in Calendar


    System.out.println("Date :"+cal.get(Calendar.DATE));
    System.out.println("Month :"+cal.get(Calendar.MONTH));
    System.out.println("Year :"+cal.get(Calendar.YEAR));

    return true;
    }

    calling the function.
    addDate(30);

    But the output is giving wrongly, previously for couple of months it was working fine, but now I don't understand why the date function is throwing wrong error
    Date :31
    Month :2
    Year :2009


    I don't understand what to do!

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 4
    Last Post: 01-10-2009, 12:17 AM
  2. event handler not working properly
    By H3rtaherta in forum Java 2D
    Replies: 3
    Last Post: 11-24-2008, 02:39 AM
  3. Menu item not working properly for mouse events
    By Preethi in forum New To Java
    Replies: 1
    Last Post: 09-23-2008, 08:56 AM
  4. My code is not working properly ..modify it
    By Shyam Singh in forum New To Java
    Replies: 14
    Last Post: 07-16-2008, 05:48 PM
  5. Log4j not working properly....
    By prakash_dev in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 12:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •