Java DateFormat.parse(String source)

Syntax

DateFormat.parse(String source) has the following syntax.

public Date parse(String source)  throws ParseException

Example

In the following code shows how to use DateFormat.parse(String source) method.


import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
//from www.  j a v a  2 s  .  c  om
public class Main {
  public static void main(String[] argv) throws Exception {

    Date date = DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.CANADA).parse("21.33.03");
    System.out.println(date);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.text »




DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat