www.webdeveloper.com
Results 1 to 3 of 3

Thread: Subtracting and getting a Date Value

  1. #1
    Join Date
    Dec 2010
    Posts
    39

    Subtracting and getting a Date Value

    Hi Guys,

    Am a newbie to java .....I want to subtract 7 days from a Date(Fetched from database) and have to get that subtracted date..(eg.) if my database date is 11-03-2011., i have to subtract 7 days from it. and i hav to get as 04-03-2011 as output..i tried but couldn't get it..pls help me as am new to this field...



    Thanks in advance,

    daya.k

  2. #2
    Join Date
    Sep 2010
    Posts
    160
    Hello,

    if you have a Date object you can create a Calendar object from that Date.

    Calendar cal = new Calendar();
    cal.setTime(yourDbDate);
    cal.add(Calendar.DATE, -7);

    Archie

  3. #3
    Join Date
    Dec 2010
    Posts
    39
    Thank u very much mate...that was very helpful

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles