Here you can find the source of formatMonth(final Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String formatMonth(final Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM"); /**// ww w .j a v a 2 s .c o m * Format the Date using pattern "yyyy-MM" * * @param date * @return */ public static String formatMonth(final Date date) { return formatMonth(date, null); } public static String formatMonth(final Date date, final String defaultValue) { if (date == null) { return defaultValue; } return monthFormat.format(date); } }