Here you can find the source of format(long timeMillis, String pattern)
Parameter | Description |
---|---|
timeMillis | a parameter |
pattern | a parameter |
public static String format(long timeMillis, String pattern)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w ww . j a v a 2s .c o m*/ * @param timeMillis * @param pattern * @return String */ public static String format(long timeMillis, String pattern) { if (timeMillis > 0L) { DateFormat dateFormat = new SimpleDateFormat(pattern); return dateFormat.format(new Date(timeMillis)); } return ""; } /** * @param date * @param pattern * @return String */ public static String format(Date date, String pattern) { if (date == null) { return ""; } DateFormat dateFormat = new SimpleDateFormat(pattern); return dateFormat.format(date); } }