Here you can find the source of asDate(Date date, String format)
Parameter | Description |
---|---|
date | a parameter |
format | a parameter |
public static String asDate(Date date, String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//w w w .ja va 2s . c o m * Formats a Date based on the provided format. If the date is null, 'Unknown' will be returned * * @param date * @param format * @return */ public static String asDate(Date date, String format) { return asDate(date, format, "Unknown"); } /** * Formats a Date based on the provided format. If the date is null, the default value will be returned * * @param date * @param format * @return */ public static String asDate(Date date, String format, String dft) { if (date == null) return dft; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }