×

Discussion Board

Results 1 to 6 of 6

Thread: date problem

  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Exclamation date problem

    do we have any function in j2me so that we can validate the date and can say whether the date obtained is future date or past date from current date.

    thanks and regards
    Arunesh

  2. #2
    Super Contributor
    Join Date
    Jan 2007
    Location
    Bhubaneswar, India
    Posts
    1,189

    Re: date problem

    Quote Originally Posted by Arunesh View Post
    do we have any function in j2me so that we can validate the date and can say whether the date obtained is future date or past date from current date.

    thanks and regards
    Arunesh
    check this FN wiki which have date and time example.
    http://wiki.forum.nokia.com/index.ph...ime_in_Java_ME
    -------------------------------------
    Thanks & Regards
    Ram
    Symbian OS 9.2/9.3,S60 3rd FP1/FP2,Carbide.c++v2.0

  3. #3
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Exclamation Re: date problem

    this is not what i want , i want to compare if 5 dec 2010(for eample) to future date or past date.

    thanks and regards
    Arunesh

  4. #4
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Exclamation Re: date problem

    This is the function i have made to compare if the given date is of future or not , argument passed to the method is value of dateField tokenized on space character .

    argument passed to the function is of the form ....

    String dat = dateField.getDate().toString();
    StringTokenizer tokenizer = new StringTokenizer(dat, " ");
    String[] date_v = tokenizer.toArray();

    boolean value = validate_date(date_v);

    the body of validate_date() function is given below , i have elaborated every step hence it looks big.

    private boolean validate_date(String[] date_validate) {

    int index_v = 0,index_c = 0;
    String[] month = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
    String d_v1 = date_validate[2];
    int d_v = Integer.parseInt(d_v1);
    String day_v = date_validate[0];
    String month_v = date_validate[1];
    String year_v1 = date_validate[5];
    int year_v = Integer.parseInt(year_v1);
    System.out.println("Date to be validated = "+d_v);
    System.out.println("Day of the week to be validated = "+day_v);
    System.out.println("month to be validated = "+month_v);
    System.out.println("year to be validated = "+year_v);

    // current date strings


    Date d1 = new Date();
    System.out.println(d1);
    String d = d1.toString();
    StringTokenizer tokenizer = new StringTokenizer(d, " ");
    String[] date_v = tokenizer.toArray();
    String d_c1 = date_v[2];
    int d_c = Integer.parseInt(d_c1);
    String day_c = date_v[0];
    String month_c = date_v[1];
    String year_c1 = date_v[5];
    int year_c = Integer.parseInt(year_c1);
    System.out.println("current date = "+d_c);

    System.out.println("current month= "+month_c);
    System.out.println("current year = "+year_c);
    for(int i = 0; i<= month.length-1;i++)
    {
    if(month_v.equals(month[i]))
    {
    index_v = i;
    index_v = index_v+1;
    System.out.println("number of given the month to be validated = "+index_v);
    }
    if(month_c.equals(month[i]))
    {
    index_c = i;
    index_c = index_c+1;
    System.out.println("number of the current month to be validated = "+index_c);
    }

    }


    System.out.println( "year = "+year_v+"date = "+d_v+"month number = "+index_v);
    System.out.println( "current year = "+year_c+"current date = "+d_c+"current month number = "+index_c);
    if(year_v >= year_c)
    {
    if(index_v >= index_c)
    {
    if(d_v >= d_c)
    {
    return true;
    }
    else if((month_v.equals(month_c))&&(year_c == year_v))
    {
    return false;
    }
    else
    return true;
    }
    else
    return false;

    }
    else
    return false;





    }

  5. #5
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Pune
    Posts
    189

    Re: date problem

    Hello Arunesh,

    Here is one more alternative for your problem & solution.
    Regards,
    Dinanath


    It's a matter of attitude.

  6. #6
    Regular Contributor
    Join Date
    Oct 2007
    Location
    Pune
    Posts
    189

    Re: date problem

    Dear qi210xi,

    What is the significance of your answer to this problem?

    You pasted the same thing for another threads also?

    If you want to post News/Announcement post here
    Regards,
    Dinanath


    It's a matter of attitude.

Similar Threads

  1. Alarm Time Problem for Anniversary
    By ChavadaSanjay in forum Symbian
    Replies: 2
    Last Post: 2009-05-30, 20:55
  2. Problem with RFs::SetModified() date
    By nroyer in forum Symbian
    Replies: 0
    Last Post: 2008-06-03, 16:23
  3. Date item problem
    By Archana Muralidhar in forum Mobile Java General
    Replies: 2
    Last Post: 2008-05-24, 05:52
  4. Nokia 6600 Date Api problem
    By ghanshyam joshi in forum General Development Questions
    Replies: 4
    Last Post: 2006-11-17, 01:45
  5. Problem with Colon " : " Date Separator
    By rave_symbian in forum Symbian
    Replies: 0
    Last Post: 2004-12-07, 08:39

Posting Permissions

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