Here you can find the source of formatDate(Date pDate, boolean pShowDateOnly)
Parameter | Description |
---|---|
pDate | a parameter |
pShowDateOnly | if true, only show date "yyyy-MM-dd" |
public static String formatDate(Date pDate, boolean pShowDateOnly)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// www . j a v a2s . c o m * Format the date to ISO 8601 format: "yyyy-MM-dd'T'HH:mm:ss" * * @param pDate * @param pShowDateOnly if true, only show date "yyyy-MM-dd" * @return */ public static String formatDate(Date pDate, boolean pShowDateOnly) { if (pDate == null) { return ""; } SimpleDateFormat dateFormat = null; if (pShowDateOnly) { dateFormat = new SimpleDateFormat("yyyy-MM-dd"); } else { dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); } return dateFormat.format(pDate); } }