Java Format - 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 w ww.  ja  v  a2  s  .c o m
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.