convert String format into date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itsmesrini85
    New Member
    • Apr 2007
    • 6

    #1

    convert String format into date

    HI

    i have a string "sdate" which has a date in the format "dd-MMM-yyyy"

    i have to convert it into sql date format for further querying....

    plz help.
    TIA

    SRI
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by itsmesrini85
    HI

    i have a string "sdate" which has a date in the format "dd-MMM-yyyy"

    i have to convert it into sql date format for further querying....

    plz help.
    TIA

    SRI
    You can use

    Code:
     Date date = Date.valueOf(reverse(strDate));
    In place of reverse, put a function that reverses a String

    Comment

    • itsmesrini85
      New Member
      • Apr 2007
      • 6

      #3
      Originally posted by r035198x
      You can use

      Code:
       Date date = Date.valueOf(reverse(strDate));
      In place of reverse, put a function that reverses a String
      hi...
      thanks for the reply.. but could you be more specific and clear.. coz am a newbie in java....

      TIA
      Sri

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by itsmesrini85
        hi...
        thanks for the reply.. but could you be more specific and clear.. coz am a newbie in java....

        TIA
        Sri
        Where do you not understand?

        Comment

        • itsmesrini85
          New Member
          • Apr 2007
          • 6

          #5
          how to reverse a string>??? which function cvan be used???

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by itsmesrini85
            how to reverse a string>??? which function cvan be used???
            Use a StringBuffer. It already has a reverse method in it.

            Comment

            • itsraghz
              New Member
              • Mar 2007
              • 124

              #7
              Hi,

              You can use the parse() method of java.text.DateF ormat object which takes the String object and gives you the java.util.Date which you can later convert it into java.sql.Date.

              You can even use java.text.Simpl eDateFormat class as well. Look at the APIs for more details. http://java.sun.com/j2se/1.4.2/docs/....ParsePosition)

              You can use the format() method for the reverse. (getting the String from the Date value)

              Hope this helps.

              Comment

              • itsmesrini85
                New Member
                • Apr 2007
                • 6

                #8
                hi all...
                thanx for ur replies... got the solution..
                Regds
                Sri

                Comment

                Working...