Java Month Convert monthIndexAsString(Integer index, Integer offset)

Here you can find the source of monthIndexAsString(Integer index, Integer offset)

Description

month Index As String

License

Open Source License

Declaration

public static String monthIndexAsString(Integer index, Integer offset) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static String monthIndexAsString(Integer index, Integer offset) {
        if (index == null) {
            return "";
        }//from  w w w .  j  av  a2 s.c o  m

        index = index - offset + 1;

        String result = "";

        SimpleDateFormat numberFormat = new SimpleDateFormat("MM");
        SimpleDateFormat stringFormat = new SimpleDateFormat("MMMM",
                Locale.US);

        try {
            Date date = numberFormat.parse(index.toString());
            result = stringFormat.format(date);
        } catch (Exception e) {
        }

        return result;
    }
}

Related

  1. month(Date date, Locale locale)
  2. month2String(Date date)
  3. monthAgo()
  4. monthConvertToNumber(String str)
  5. monthformMatDate(Date date)
  6. monthNumber(String s)
  7. monthOfDate(Date s)
  8. monthsBetween(String from, String to)
  9. monthStringToInt(String month)