Java Date parse String like "02.36.33 PM"

Description

Java Date parse String like "02.36.33 PM"

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

  static public void main(String[] args) {
    DateFormat formatter = new SimpleDateFormat("hh.mm.ss a");
    Date date = null;//ww  w  .ja  v a2 s . c  o m
    try {
      date = (Date) formatter.parse("02.36.33 PM");
    } catch (ParseException e) {
      e.printStackTrace();
    }
    System.out.println(date);
  }
}



PreviousNext

Related