Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

stepping through java GregorianCalendar Class wtf!!

  • 11-02-2004 09:06PM
    #1
    Registered Users, Registered Users 2 Posts: 261 ✭✭


    i had problem filling a vector with dates start at certain date and add 1 till i got the end date
    The problem is that when i get to a certain point it then throws illegal argument
    Exception i have step through it and cant find why it does this, maybe i need to difine the start date and end date better i managed to get it working by changing the date around a bit i think it some thing with start date being smaller then the end date any info would be good
    Code:
    Constructing new object:
    new TarifType(new GregorianCalendar(2004, 6, 5,0,0,0),
    new GregorianCalendar(2004, 7, 25,0,0,0),
    sePrices,"Super Economy");

    That objects constructer:
    public TarifType(GregorianCalendar startDate,GregorianCalendar endDate,Tarifs[] tarifsIn,String strTitleIn)
    {
    tarifPeriod.add((GregorianCalendar)startDate);
    int j= startDate.get(startDate.DAY_OF_MONTH);
    strTitle = strTitleIn;
    //While which checks if the start date is equal to the end date
    while( startDate.get(startDate.MONTH) != endDate.get(endDate.MONTH) &&
    startDate.get(startDate.DAY_OF_MONTH ) != endDate.get(endDate.DAY_OF_MONTH) )
    {
    //method that add 1 to the DAY_OF_MONTH field
    startDate.add(j, 1);

    //creates new GregorianCalendar to be inserted into the vector
    GregorianCalendar addEelment = new GregorianCalendar(
    startDate.get(startDate.YEAR )
    ,startDate.get(startDate.MONTH),
    startDate.get(startDate.DAY_OF_MONTH));
    //adds date to vector using siad method
    addDate(addEelment);

    }
    public void addDate(GregorianCalendar DateIn)
    {
    tarifPeriod.add(DateIn);
    }

    Code is a bit messed up i was trying every thing to get work
    i have it workish :ninja:
    just curious that the problem was and is :mad:


Advertisement