Java Date Format Pattern getMMDDYYHHMM()

Here you can find the source of getMMDDYYHHMM()

Description

get MMDDYYHHMM

License

Open Source License

Declaration

public static String getMMDDYYHHMM() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Boeing./*from ww w . j  a v a  2 s.com*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String MMDDYYHHMM = "MM/dd/yyyy hh:mm a";

    public static String getMMDDYYHHMM() {
        return getMMDDYYHHMM(new Date());
    }

    public static String getMMDDYYHHMM(Date date) {
        return get(date, MMDDYYHHMM);
    }

    public static String get(Date date) {
        if (date == null) {
            return "";
        }
        return DateFormat.getDateInstance().format(date);
    }

    public static String get(Date date, String pattern) {
        return get(date, new SimpleDateFormat(pattern));
    }

    public static String get(Date date, DateFormat dateFormat) {
        if (date == null) {
            return "";
        }
        String result = dateFormat.format(date);
        return result;
    }
}

Related

  1. getLenientFormat(String format)
  2. getMM()
  3. getMM(Date date)
  4. getMM(String strDate)
  5. getMMdd()
  6. getMMDDYYYY(final Date date, final String separator)
  7. getMomentFormatter()
  8. getPooledSDF(String format)
  9. getSdf(String formatPattern)