Java Long Number to Date formatDateForLog(long dateTs)

Here you can find the source of formatDateForLog(long dateTs)

Description

format Date For Log

License

MIT License

Declaration

public static String formatDateForLog(long dateTs) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright ? 2012-2015 eBay Software Foundation
 *  This program is dual licensed under the MIT and Apache 2.0 licenses.
 *  Please see LICENSE for more information.
 *******************************************************************************/

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

public class Main {
    private static final String LOG_TS_FORMAT = "yyyyMMdd_HH:mm:ss";

    public static String formatDateForLog(long dateTs) {
        return formatDate(dateTs, LOG_TS_FORMAT);
    }// w w w. j  av a  2s .  com

    public static String formatDate(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }

    public static String formatDate(long dateTs, String format) {
        return formatDate(new Date(dateTs), format);
    }
}

Related

  1. formatDate(long timeStamp)
  2. formatDate(long timestamp, String format)
  3. formatDate(String format, long timestamp)
  4. formatDate2DateStr(long date)
  5. formatDate2DateStr(long date)
  6. formatDateHeader(final long date)
  7. formatDateHeader(final long date)
  8. formatDateHeader(long millis)
  9. formatDateHeader(long value)