Java Locale Format formatMailDate(Date date)

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

Description

Format the date.

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static String formatMailDate(Date date) 

Method Source Code

//package com.java2s;
/* MessageUtils.java// w  w w  . j  a va2s  .c  o  m
    
   Copyright (c) 2009 Juergen Schlierf, All Rights Reserved
       
   This file is part of Cubusmail (http://code.google.com/p/cubusmail/).
       
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.
       
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.
       
   You should have received a copy of the GNU Lesser General Public
   License along with Cubusmail. If not, see <http://www.gnu.org/licenses/>.
       
 */

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    /**
     * Format the date.
     * 
     * @param date
     * @return
     */
    public static String formatMailDate(Date date) {

        if (date != null) {
            DateFormat format = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM,
                    SimpleDateFormat.SHORT, Locale.GERMAN);

            return format.format(date);
        } else {
            return "";
        }
    }
}

Related

  1. formatInteger(Long num)
  2. formatIntWithCommas(int num)
  3. formatLines(String target, int maxLength, Locale currentLocale)
  4. formatLocaleDate(final java.util.Date date)
  5. formatLocaleTime(long time, Locale locale)
  6. formatMessage(@Nonnull ResourceBundle bundle, @Nonnull String messageKey, @Nullable Object... args)
  7. formatMessage(String messageKey, Locale locale)
  8. formatMysqlDate(final Date date)
  9. formatNumber(double d, String pattern)