Results 1 to 6 of 6
  1. #1
    victoryo is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Search data for a month

    I got a question.

    I have a jtable with a date field where the date is stored like this "31-12-2012" in a String.
    I know i have to give a parameter to search the in the jtable but how can i say that i want only the data from the 12th month?
    Hope someone can give some hints! :D

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Search data for a month

    What class type does the table model hold for that column? Does it hold java.util.Date data or String data?

  3. #3
    victoryo is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Search data for a month

    It's a String[] :)

  4. #4
    victoryo is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Search data for a month

    I think i maybe found a Solution with contains substring?
    or tell me if iam totaly wrong:p

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Search data for a month

    Quote Originally Posted by victoryo View Post
    I think i maybe found a Solution with contains substring?
    or tell me if iam totaly wrong:p
    That could work, or a regular expression.

  6. #6
    victoryo is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Search data for a month

    Could you tell me how i can search the data in my Jtable?

    My table looks like this:

    Java Code:
    if (kilometers.size() > 0 || bestuurders.size() > 0)
    {
        for (int i = 0; i < kilometers.size(); i++)
        {
        Kilometer kilometer = (Kilometer)kilometers.get(i);
        Bestuurder bestuurder = (Bestuurder)bestuurders.get(i);
    
        model.addRow(new String[]{bestuurder.getNaam(), bestuurder.getDate(), kilometer.getBeginstand() + " KM"
                , kilometer.getEindstand() + " KM", kilometer.getAfstand() + " KM"," " + totaalPrijs(i)}); 
        }
    }
    I thought with something like this:

    Java Code:
        String datum = bestuurder.getDate().substring(3, 5);
        if(datum.equals(Datum) && bestuurder.getNaam().contains(Naam))
    But i don't exactly know how to implement it! :(:P

Similar Threads

  1. Replies: 4
    Last Post: 03-24-2011, 11:50 PM
  2. Replies: 0
    Last Post: 04-04-2010, 07:40 AM
  3. Replies: 0
    Last Post: 10-29-2009, 09:28 AM
  4. Replies: 5
    Last Post: 08-26-2008, 03:43 PM
  5. Replies: 0
    Last Post: 04-04-2008, 09:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •