Parse a Time with "hh.mm.ss a" format in Java

Description

The following code shows how to parse a Time with "hh.mm.ss a" format.

Example


//from   ww w.ja  va  2  s  .com
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
  public static void main(String[] argv) throws Exception {

    DateFormat formatter = new SimpleDateFormat("hh.mm.ss a");
    Date date = (Date) formatter.parse("02.47.44 PM");
    System.out.println(date);
  }
}

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