Results 1 to 2 of 2

Thread: Converting String to Date object in java

  1. #1
    AndersonDiaz is offline Senior Member
    Join Date
    Dec 2009
    Posts
    311
    Rep Power
    3

    Default Converting String to Date object in java

    I just began to study java language. I want to know How to convert String to Date object in java. Please help me.

  2. #2
    TaylorRyan is offline Senior Member
    Join Date
    Dec 2009
    Posts
    307
    Rep Power
    3

    Default

    1) Following code shows how to convert string to date:

    import java.util.*;

    import java.text.*;

    public class StringToDate {
    public static void main(String[] args) {
    try { String str_date="18-January-10";
    DateFormat formatter ;
    Date date ;
    formatter = new SimpleDateFormat("dd-MMM-yy");
    date = (Date)formatter.parse(str_date);
    System.out.println("Today is " +date );
    } catch (ParseException e)
    {System.out.println("Exception :"+e); }

    }
    }

Similar Threads

  1. Altering a date to string in Visual Basic 2005
    By PerezMorris in forum other peripherals
    Replies: 1
    Last Post: 06-03-2010, 01:49 PM
  2. Replies: 1
    Last Post: 05-03-2010, 01:37 PM
  3. Converting InputStream to String in java
    By Millerjames in forum Programming
    Replies: 1
    Last Post: 01-21-2010, 03:26 PM
  4. Converting Date into a UNIX Timestamp PHP
    By ThompsonHarris in forum Programming
    Replies: 0
    Last Post: 01-11-2010, 02:42 PM
  5. Converting PHP String into Date
    By frank_clark in forum Programming
    Replies: 0
    Last Post: 01-08-2010, 05:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48