Java Hour Format formatDateTime24()

Here you can find the source of formatDateTime24()

Description

format Date Time

License

Open Source License

Declaration

public static void formatDateTime24() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static void formatDateTime24() {
        // format 12 hours time to 24 hours time
        SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm");
        SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
        Date date = null;//w  w w .  j  a  v  a  2  s  .c  o m
        try {
            date = parseFormat.parse("10:30 PM");
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(parseFormat.format(date) + " = " + displayFormat.format(date));

    }
}

Related

  1. formatDateTime(String date)
  2. FormatDateTime(String dateString)
  3. formatDateTime(String dateTime)
  4. formatDateTime(String strDateTime, String strFormat)
  5. formatDateTime12(String dateStr)
  6. formatDateTimeForSolr(Date d)
  7. formatDateTimeFull(Date dateTime)
  8. formatDateTimeStringForEquivalentCommand(final Date date)
  9. formatDateToEndDateTime(String strDate)