×

Discussion Board

Results 1 to 3 of 3

Thread: DateField

  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    88

    DateField

    Hi guys!
    I have a question about DateField: Can I set a date using a String?
    I mean:
    String s = "2005-01-05" or String s = "2005-Jan-05"
    DateField date = new DateField("Date",DateField.DATE);

    Can I set "date" using the String s?

    Could u tell me how I could do it?

    thank you in advance

    antonio

  2. #2
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    88

    Re: DateField

    I managed using the method DateParser.parse

    The problem is that in order to use this method I have to import com.sun.midp.io.DateParser;
    it works in the emulator but I cannot install the application in my mobile phone becasue of this "import"!

    What I have to do? I think I should add some library, which one?

    antonio

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    3

    Re: DateField

    If you wanted to create your own parser (and didn't want to calculate the milliseconds yourself, though I don't see why not) you could create a Calendar object and use myCalendar.set(Calendar.MONTH, month); etc to create a new Calendar object and then myCalendar.getTime() to turn it into a Date object.

    As for you antonio, I really don't think DateParser is part of the CLDC or MIDP spec (it may be part of CDC instead of CLDC, I'm not sure).

    The good news is that now that J2ME is open source you could download the source code for it and hack it into your own code. Look for the PhoneME project (it's run by Sun themselves) on a search engine. It might be in there. Let us know how you go.

Similar Threads

  1. J2ME DateField
    By bikerzon in forum Mobile Java General
    Replies: 8
    Last Post: 2010-03-25, 08:48
  2. DateField can't set time to PM in 12hr mode
    By ashneo75 in forum Mobile Java General
    Replies: 0
    Last Post: 2006-04-06, 15:19
  3. DateField on Nokia 3220 (Series 40)
    By TheWheat in forum Mobile Java General
    Replies: 0
    Last Post: 2006-03-28, 21:42
  4. DateField won't show time
    By mehli2002 in forum Mobile Java General
    Replies: 0
    Last Post: 2005-05-05, 14:46
  5. DateField and itemStateChanged
    By kaywin in forum Mobile Java General
    Replies: 3
    Last Post: 2003-11-17, 09:10

Posting Permissions

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