Results 1 to 3 of 3
  1. #1
    KeeFy is offline Member
    Join Date
    Apr 2009
    Rep Power

    Default [SOLVED] Calendar help

    I got a date formated as YY,MM,DD as data in thedates. Problem is how do i get it to set into the Calendar? It seems i can't use any variables?

    Thanks in advance!

    Java Code:
         Calendar abcd = Calendar.getInstance();
         int typeofchart = 1;                           // SETS THE TYPE OF CHART
         String datestrip[] = thedates.split(",");
         //abcd.set (2006,5,30);                       
          // abcd.set(datestrip[0],datestrip[1],datestrip[2]);
           abcd.set(Calendar.YEAR, datestrip[0]);
           abcd.set(Calendar.MONTH, datestrip[1]);
           abcd.set(Calendar.DATE, datestrip[2]);

  2. #2
    KeeFy is offline Member
    Join Date
    Apr 2009
    Rep Power


    Nevermind! I took one more look at the class and i realised it should be in int! Silly mistake. Thanks. :)

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Rep Power


    Calendar.set() takes two ints

    Java Code:
    abcd.set(Calendar.YEAR, Integer.parseInt(datestrip[0]));
    abcd.set(Calendar.MONTH, Integer.parseInt(datestrip[1]));
    abcd.set(Calendar.DATE, Integer.parseInt(datestrip[2]));
    Edit: ok, nevermoind me then ;)

Similar Threads

  1. How to add a calendar????
    By zifis in forum New To Java
    Replies: 5
    Last Post: 04-07-2009, 05:04 PM
  2. Calendar bug?
    By Stigvig in forum Advanced Java
    Replies: 14
    Last Post: 02-08-2009, 10:56 AM
  3. calendar
    By John in forum SWT / JFace
    Replies: 12
    Last Post: 08-07-2008, 11:54 PM
  4. How to Show Calendar
    By praveen.kb in forum AWT / Swing
    Replies: 2
    Last Post: 02-09-2008, 09:23 AM
  5. Web calendar
    By Daniel in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 06-27-2007, 06:36 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