Loading ...
Sorry, an error occurred while loading the content.
 

Menambah/mengurangi bulan pd Date?

Expand Messages
  • fallenange7@yahoo.com
    Misal Date tgl1 = new SimpleDateFormat( dd-MM-yyyy ).parse( 01-09-2008 ); //Lalu, saya ingin agar pergi ke 2 bln berikutnya //Hasilny jd Date tgl1 = new
    Message 1 of 3 , Oct 1, 2009
      Misal

      Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-09-2008");

      //Lalu, saya ingin agar pergi ke 2 bln berikutnya
      //Hasilny jd
      Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-11-2008");

      Bagaimana syntaxny?
    • Ifnu bima
      ... ini udah bener. Atau kalau gak mau repot bikin gini nih : Date sekarang = new Date(); Calendar c = Calendar.getInstance(); c.setTime(sekarang);
      Message 2 of 3 , Oct 1, 2009
        > Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-09-2008");
        >
        > //Lalu, saya ingin agar pergi ke 2 bln berikutnya
        > //Hasilny jd
        > Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-11-2008");

        ini udah bener.


        Atau kalau gak mau repot bikin gini nih :

        Date sekarang = new Date();

        Calendar c = Calendar.getInstance();

        c.setTime(sekarang);

        c.add(Calendar.MONTH,2);

        Date duaBulanLagi = c.getTime();



        --
        Senior Engineer @ ArtiVisi Intermedia
        Java Training Center
        See our course @ artivisi.com

        http://ifnu.artivisi.com
        +62 856 9211 8687
        regards
      • Martinus Ady H
        ... Coba main-main ke sini[1] ^_^ [1] http://martinusadyh.web.id/2007/10/06/playing-with-calendar-class/ -- Martinus Ady H. Registered Linux User #410906
        Message 3 of 3 , Oct 1, 2009
          fallenange7@... wrote:
          > Misal
          >
          > Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-09-2008");
          >
          > //Lalu, saya ingin agar pergi ke 2 bln berikutnya
          > //Hasilny jd
          > Date tgl1 = new SimpleDateFormat("dd-MM-yyyy").parse("01-11-2008");
          >
          > Bagaimana syntaxny?
          >

          Coba main-main ke sini[1] ^_^

          [1] http://martinusadyh.web.id/2007/10/06/playing-with-calendar-class/

          --
          Martinus Ady H.
          Registered Linux User #410906
          Personal Blog : http://martinusadyh.web.id/
          Planet NetBeans ID : http://planetnetbeans.org/id/index.html
          Planet Slackware ID : http://planet.slackware-id.org/
        Your message has been successfully submitted and would be delivered to recipients shortly.