Java examples for java.util:Month
get Current Month Label
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getCurrentMonthLabel()); }// w w w .jav a 2 s .c o m public static String getCurrentMonthLabel() { Calendar calendar = Calendar.getInstance(); String name = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()); return name.substring(0, 1).toUpperCase() + name.substring(1); } public static String getCurrentMonthLabel(Date date) { if (date == null) { return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); String name = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()); return name.substring(0, 1).toUpperCase() + name.substring(1); } }