Java Utililty Methods Month Format

List of utility methods to do Month Format

Description

The list of methods to do Month Format are organized into topic(s).

Method

StringaddMonths(String src, int addMonth, String format)
add Months
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
SimpleDateFormat informatter = new SimpleDateFormat("yyyyMMdd", Locale.UK);
SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy", Locale.UK);
SimpleDateFormat monthFormat = new SimpleDateFormat("MM", Locale.UK);
SimpleDateFormat dayFormat = new SimpleDateFormat("dd", Locale.UK);
DecimalFormat fourDf = new DecimalFormat("0000");
DecimalFormat twoDf = new DecimalFormat("00");
Calendar calendar = Calendar.getInstance(Locale.UK);
...
StringformatMonth(Date date)
format Month
if (date == null) {
    return null;
return new SimpleDateFormat(monthFormat).format(date);
StringformatMonth(Date date)
format Month
if (date == null) {
    return NOT_DEFINED_DATE;
return monthDF.format(date.getTime());
StringformatMonth(final Date date)
Format the Date using pattern "yyyy-MM"
return formatMonth(date, null);
StringformatMonth(final int year, final int month)
format Month
final StringBuffer buf = new StringBuffer();
buf.append(year);
if (month >= 0) {
    buf.append('-');
    final int m = month + 1;
    if (m <= 9) {
        buf.append('0');
    buf.append(m);
return buf.toString();
StringformatMonth(int month)
format Month
return MONTH_FORMAT[month];
StringformatMonth(int month, Locale locale, boolean longFormat)
format Month
SimpleDateFormat sdf = new SimpleDateFormat("", getSafeLocale(locale));
if (longFormat)
    return sdf.getDateFormatSymbols().getMonths()[month];
else
    return sdf.getDateFormatSymbols().getShortMonths()[month];
StringformatMonth(String dateOrign)
format Month
String dateString = "";
try {
    dateString = new SimpleDateFormat("ddMMMyyyy", Locale.US)
            .format(new SimpleDateFormat("yyyy-MM-dd").parse(dateOrign));
} catch (Exception e) {
    return "";
return dateString;
...
StringformatMonthDay(int decimal)
format Month Day
DecimalFormat df = new DecimalFormat("00");
return df.format(decimal);
StringformatMonthlyPeriod(String month)
format Monthly Period
String[] monthNames = { "January", "February", "March", "April", "May", "June", "July", "August",
        "September", "October", "November", "December" };
StringBuffer formattedPeriod = new StringBuffer();
String m = month.substring(0, month.indexOf(" "));
String y = month.substring(month.indexOf(" ") + 1, month.length());
int mnth = -1;
for (int i = 0; i < monthNames.length; i++) {
    if (monthNames[i].equals(m)) {
...