Java Long Number to Date formatDate(long epochMillis)

Here you can find the source of formatDate(long epochMillis)

Description

Standard Date/time format for CSV files

License

Open Source License

Parameter

Parameter Description
epochMillis a parameter

Return

String formatted string (i.e. '11/4/03')

Declaration

public static String formatDate(long epochMillis) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.j a v a2 s  .co m*/
 *
 *  * RHQ Management Platform
 *  * Copyright (C) 2005-2012 Red Hat, Inc.
 *  * All rights reserved.
 *  *
 *  * This program is free software; you can redistribute it and/or modify
 *  * it under the terms of the GNU General Public License as published by
 *  * the Free Software Foundation version 2 of the License.
 *  *
 *  * This program 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 General Public License for more details.
 *  *
 *  * You should have received a copy of the GNU General Public License
 *  * along with this program; if not, write to the Free Software
 *  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

import java.text.DateFormat;
import java.util.Date;

public class Main {
    /**
     * Standard Date/time format for CSV files
     * @param epochMillis
     * @return String formatted string (i.e. '11/4/03')
     */
    public static String formatDate(long epochMillis) {
        if (epochMillis != 0) {
            Date date = new Date(epochMillis);
            return DateFormat.getDateInstance(DateFormat.SHORT)
                    .format(date);
        } else {
            return " ";
        }
    }
}

Related

  1. formatDate(long date)
  2. formatDate(Long date, String fmt)
  3. formatDate(long date, String format)
  4. formatDate(long date, String langStr)
  5. formatDate(long dateValue)
  6. formatDate(long millis)
  7. formatDate(long millis)
  8. formatDate(long millis)
  9. formatDate(long millis, Locale locale)