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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

splitting a date

  • 18-02-2004 11:47am
    #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, Registered Users 2 Posts: 2,013 ✭✭✭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