Parse a Date Object From a String in the format of Saturday, July 4, 1998 in Java

Description

The following code shows how to parse a Date Object From a String in the format of Saturday, July 4, 1998.

Example


//w  w  w. j  ava2 s  . c  om
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class Main {
  public static void main(String[] a) {
    Date aDate;
    DateFormat fmt = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
    try {
      aDate = fmt.parse("Saturday, July 4, 1998");
      System.out.println("The Date string is: " + fmt.format(aDate));
    } catch (java.text.ParseException e) {
      System.out.println(e);
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone