Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor rajan701v's Avatar
    Join Date
    Dec 2009
    Location
    Ghaziabad
    Posts
    244
    Hi everyone!!
    I got stuck of this problem. How do i compare two dates in J2me. Please provide me some source code if anyone have. Please it's an urgent requirement.

    Please Reply.
    Regards
    Rajan Verma

  2. #2
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    Well, it would help if you told us more about your situation... Like whether you're talking about the Date class or something else.

    Does the equals method do what you need? If not, you could use the getTime method and compare the resulting numbers.
    Last edited by bogdan.galiceanu; 2011-02-17 at 11:21.

  3. #3
    Regular Contributor rajan701v's Avatar
    Join Date
    Dec 2009
    Location
    Ghaziabad
    Posts
    244
    Quote Originally Posted by bogdan.galiceanu View Post
    Well, it would help if you told us more about your situation... Like whether you're talking about the Date class or something else.

    Does the equals method do what you need? If not, you could use the getTime method and compare the resulting numbers.
    Thanks for the reply..
    I want to compare the dates in the followin format :
    compareDate(todayDate,selectedDate)

    todayDate is the Current Date.
    Selected date is Date selected fromt the Calendar.
    Now the difference between the two dates could not be greter than 6 months.
    That is the
    Date d = todyaDate - selectedDate (Let for an example).
    d should not be greater than 6 months.
    Please Reply.
    Last edited by rajan701v; 2011-02-17 at 11:18.
    Regards
    Rajan Verma

  4. #4
    Registered User bhanuchandar.k's Avatar
    Join Date
    Sep 2007
    Location
    Bangalore
    Posts
    868
    Hi rajan,

    I don't know about the LWUIT . But normally you can do like if you have current date in millis and past date in millis

    You an do like :

    long currentDateMilliSec = curent time
    long selecteddate= selected date
    long diffDays = (currentDateMilliSec - selecteddate) / (24 * 60 * 60 * 1000);
    With this you will get the number of days now you can check the difference.

  5. #5
    Regular Contributor rajan701v's Avatar
    Join Date
    Dec 2009
    Location
    Ghaziabad
    Posts
    244
    Ok. I will reply for the same.

    Is it possible to create our own Calendar. With our own look and feel.

    Please Reply.
    Regards
    Rajan Verma

  6. #6
    Registered User iwalulya's Avatar
    Join Date
    Apr 2011
    Posts
    2
    Quote Originally Posted by rajan701v View Post
    Hi everyone!!
    I got stuck of this problem. How do i compare two dates in J2me. Please provide me some source code if anyone have. Please it's an urgent requirement.

    Please Reply.
    Hey Rajan hope this is not late, however with dates you can us dateObject.getTime() to get the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.


    Then you use those seconds for comparison

    example
    long timeDiff = selectedDate.getTime() - todyaDate.getTime() ;

    Then u can compute whatever you want using the timeDiff variable which is in milliseconds.

    Regards
    Ivan Walulya

  7. #7
    Nokia Developer Champion im2amit's Avatar
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    2,917
    Quote Originally Posted by rajan701v View Post
    Ok. I will reply for the same.

    Is it possible to create our own Calendar. With our own look and feel.

    Please Reply.
    Yes, it possible either extend the LWUIT Canlendar component or create your own extending LWUIT form.

    Refer to --> http://wiki.forum.nokia.com/index.ph...ar/date_picker
    thanks,
    ~Amitabh
    (Poster of the Month -Dec'12)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. how to compare two vcards
    By chinnu_p in forum Symbian C++
    Replies: 4
    Last Post: 2009-08-11, 07:07
  2. Voice Recognition 6600: How to compare two AMR files?
    By fmartin5 in forum Mobile Java General
    Replies: 3
    Last Post: 2009-05-12, 10:21
  3. how to compare two images
    By nehasaxena in forum Symbian C++
    Replies: 4
    Last Post: 2009-03-25, 13:46
  4. how to compare 2 Dates?
    By rohanwaugh in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-12-12, 11:28
  5. how to compare the contents of two buffers
    By Bhoopathi Kummara in forum Symbian C++
    Replies: 2
    Last Post: 2007-10-09, 11:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved