Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to convert String to Date

Thread Tools

How to convert String to Date

javaeecoding javaeecoding is offline
Junior Member
Join Date: Sep 2008
Posts: 1
The codes below show you how to convert String to Date in Java.

The copyright of the codes belongs to

HTML Code:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date; 

public class StringToDateConverter 
    public static void main(String[] args)    
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");         
             // to convert String to Date in format yyyy-MM-dd            
             Date date1 = dateFormat1.parse("2008-08-09");
             System.out.println("date1 = " + date1);        
        catch (ParseException ex)        
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Convert date recevied as String to date in local time zone C++ 8 05-01-2007 12:26 PM
Ordinal Date String to Standard Date String for a Beginner davyb Ruby 7 11-18-2005 08:54 PM
how can I convert date infomation to a string just includes the date not the time wgan Java 7 07-08-2004 07:08 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM