Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

splitting a date

Options
  • 18-02-2004 12:47pm
    #1
    Closed Accounts Posts: 537 ✭✭✭


    I am retrieving a date from a combo box and want to split the date i want to convert the each segment of the date into an integer and and perform maths functions on it here is what i have so far but im a wee bit stuck any help would be much appreciated thanks

    int date;
    String sql = "Select Accepts.TimeOfAccept FROM Accepts where Accepts.TimeOfAccept = 'jComboBox2';";
    ResultSet result = stmt.executeQuery(sql);
    date= result.getInt(1);


    now obviously these lines are incompatible with the lines above due to the fact date being an integer
    String day = Date.substring(0, 2);
    String month = Date.substring(3, 5);
    String year = Date.substring(6);
    int asciiday = (int)day;
    int asciimonth = (int)month;
    int asciiyear = (int)year;
    IsleapYear (year);


Comments

  • Registered Users Posts: 1,990 ✭✭✭lynchie


    Why dont you store your date as a date object? It makes it much easier for manipulating dates. Once it is in a Date object, you can simply get the day,month and year from the date object without the hassle of substrings etc...


Advertisement