RSS Links

 

Here are all of the RSS links for sections of this site

VB.NET/ASP.NET
 Java
 Unix/Linux
 Windows
 SQL Server

Home arrow Java arrow parsing a text date in java
parsing a text date in java PDF Print E-mail
Sunday, 24 January 2010
To parse a text date in java you first need to create a SimpleDateFormat object with the pattern matching the format that the date is in, then just use the parse function to complete the parse.

The following method gives an example

public void parseDateFromString()
{
        String convDate = "21/03/2009";

        SimpleDateFormat format = new SimpleDateFormat("d/M/y");
        try {
            Date theDate = format.parse(convDate);
            System.out.println("The date to parse was " + convDate);
            System.out.println("The parsed date was " + theDate);
        } catch (ParseException pe) {
            System.out.println("Couldnt parse the date Error: " + pe);
        }
}
 
Next >
 
Designed by Graham Robinson Software