Here you can find the source of formatDate(long millis)
Parameter | Description |
---|---|
millis | the date |
public synchronized static String formatDate(long millis)
//package com.java2s; /*/*from w w w . j a v a 2 s. co m*/ * #%L * Netarchivesuite - common * %% * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, * the National Library of France and the Austrian National Library. * %% * This program 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 2.1 of the * License, or (at your option) any later version. * * 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 Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-2.1.html>. * #L% */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** Default date format : yyyy/MM/dd HH:mm:ss */ private static final SimpleDateFormat DEFAULT_DATE = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); /** * Formats the given date (as elapsed milliseconds) using the default format 'yyyy/MM/dd HH:mm:ss'. * * @param millis the date * @return a formatted date string */ public synchronized static String formatDate(long millis) { return DEFAULT_DATE.format(new Date(millis)); } /** * Formats the given date (as elapsed milliseconds) using the provided format pattern. * * @param millis the date * @param format the format pattern {@link SimpleDateFormat} * @return a formatted date string */ public static String formatDate(long millis, String format) { return new SimpleDateFormat(format).format(new Date(millis)); } }