#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    27
    Rep Power
    0

    J2me convert string to date


    Hi there,

    Im building a J2ME application. I need to convert a string to a date. Could you kindly help me with this...I was able to convert date to string...however I do not know how to convert a string to a date...I simply require a normal format such as dd-mm-yyyy.

    Im so new to J2ME....


    Thanks in advance.....
  2. #2
  3. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    I simply require a normal format such as dd-mm-yyyy.
    Wait a second; dates don't have a "format". "Format" only applies to string. You would parse a string to a Date object, or format a Date object as a string. Which of those are you having problems with?

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    27
    Rep Power
    0
    Originally Posted by Yawmark
    Wait a second; dates don't have a "format". "Format" only applies to string. You would parse a string to a Date object, or format a Date object as a string. Which of those are you having problems with?

    ~
    oh sorry....yes you are correct...

    actually i was able to convert my date/time value to string...Im having problems with converting this value back to a date/time value.
  6. #4
  7. Feelin' Groovy
    Devshed Supreme Being (6500+ posts)

    Join Date
    Aug 2001
    Location
    WDSMIA
    Posts
    10,135
    Rep Power
    5054
    Im having problems with converting this value back to a date/time value.
    You'll need to roll your own parser. Split the string up into component parts, parse the parts and use the values to set the corresponding fields in a Calendar, and call getTime() on the calendar to get the Date.

    ~
    Yawmark
    class Sig{public static void main(String...args){\u0066or(int
    \u0020$:"v\"ʲ\"vΤ\"".to\u0043h\u0061rArray()
    )System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
    +(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

IMN logo majestic logo threadwatch logo seochat tools logo