String to Date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jyohere
    New Member
    • Apr 2007
    • 73

    #1

    String to Date

    How do I convert this String 20070508164501 into Date in java
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by jyohere
    How do I convert this String 20070508164501 into Date in java
    You can make a java.util.Date or a java.sql.Date.

    Have a look at their API specs on the sun site. You may find the Date.valueOf method very useful here.

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      may I know the context whr u want this ? and exactly what errors u got?
      Originally posted by jyohere
      How do I convert this String 20070508164501 into Date in java

      Comment

      • jyohere
        New Member
        • Apr 2007
        • 73

        #4
        Originally posted by hirak1984
        may I know the context whr u want this ? and exactly what errors u got?
        Thanx i Got it.....using SimpleDateForma t
        String str="2007050816 4500";
        SimpleDateForma t dateFormat=new SimpleDateForma t("yyyyMMddHHmm ss");
        ParsePosition p=new ParsePosition(0 );
        Date date=dateFormat .parse(str[17],p);

        WAw............ ............... ....

        Comment

        Working...