Java Hour Format formatDateAsString(Date date)

Here you can find the source of formatDateAsString(Date date)

Description

format Date As String

License

Open Source License

Declaration

public static String formatDateAsString(Date date) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.  jav a  2s  . c  om*/
 * #%L
 * BroadleafCommerce Common Libraries
 * %%
 * Copyright (C) 2009 - 2016 Broadleaf Commerce
 * %%
 * Licensed under the Broadleaf Fair Use License Agreement, Version 1.0
 * (the "Fair Use License" located  at http://license.broadleafcommerce.org/fair_use_license-1.0.txt)
 * unless the restrictions on use therein are violated and require payment to Broadleaf in which case
 * the Broadleaf End User License Agreement (EULA), Version 1.1
 * (the "Commercial License" located at http://license.broadleafcommerce.org/commercial_license-1.1.txt)
 * shall apply.
 * 
 * Alternatively, the Commercial License may be replaced with a mutually agreed upon license (the "Custom License")
 * between you and Broadleaf Commerce. You may not use this file except in compliance with the applicable license.
 * #L%
 */

import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static String formatDateAsString(Date date) {
        // format date list grid cells
        SimpleDateFormat formatter = new SimpleDateFormat(
                "MMM d, Y @ hh:mma");
        DateFormatSymbols symbols = new DateFormatSymbols(
                Locale.getDefault());
        symbols.setAmPmStrings(new String[] { "am", "pm" });
        formatter.setDateFormatSymbols(symbols);

        return formatter.format(date);
    }
}

Related

  1. formatDate2DateTimeStr()
  2. formatDate2DateTimeStr()
  3. formatDate3DateTimeStr(Date date)
  4. formatDateAddHMS(String strDate)
  5. formatDateAndTime(Date date)
  6. formatDateForCERMe(Date date, boolean includeTime)
  7. formatDateInTime(Date date)
  8. formatDateRfc822(Date date, String timeZoneId)
  9. formatDateString(Date d)