Java Year Format formatyyyyMMddHHmmss(long time)

Here you can find the source of formatyyyyMMddHHmmss(long time)

Description

formatyyyy M Mdd H Hmmss

License

Open Source License

Declaration

public static String formatyyyyMMddHHmmss(long time) 

Method Source Code

//package com.java2s;
/*//from   w  w w  . jav a 2s  .co m
 * Copyright 2010 Mttang.com All right reserved. This software is the
 * confidential and proprietary information of Mttang.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Mttang.com.
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    static final SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String formatyyyyMMddHHmmss(long time) {
        return yyyyMMddHHmmss.format(new java.util.Date(time));
    }

    public static String formatyyyyMMddHHmmss(Date time) {
        if (time == null) {
            return "";
        }
        try {
            return yyyyMMddHHmmss.format(time);
        } catch (Exception ex) {
            return "";
        }
    }
}

Related

  1. formatYear(Date d, Locale locale)
  2. formatYear(Date date)
  3. formatYear(Date date)
  4. formatYearMonth(Date date)
  5. formatYyyyMm(Date date)
  6. get_Oracle_DateString_YYYYMMdd_HHmmss(java.util.Date date)
  7. getDDMMYYY_HHMM()
  8. getDDMMYYYYDate(Date date)
  9. getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat)