Java Calendar format to String like "04 o'clock PM, Pacific Standard Time"

Description

Java Calendar format to String like "04 o'clock PM, Pacific Standard Time"

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    // Create new calendar
    Calendar cal = Calendar.getInstance();

    // Create instance of SimpleDateFormat class using pattern
    SimpleDateFormat dateFormatter1 = new SimpleDateFormat("hh 'o''clock' a, zzzz");
    String result = null;/*from   www  .ja  va 2  s  .c o  m*/

    result = dateFormatter1.format(cal.getTime());
    System.out.println(result);


  }
}



PreviousNext

Related