Java Utililty Methods Month Get

List of utility methods to do Month Get

Description

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

Method

StringgetMonth(String day)
get Month
if (day == null)
    return "0";
if (day.length() < 8)
    return "0";
int m = day.indexOf("-", 0);
int n = day.lastIndexOf("-");
String temp = day.substring(m + 1, n);
if (temp.length() == 1)
...
IntegergetMonth(String f)
get Month
Integer month;
try {
    SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
    Date dt1 = format1.parse(f);
    DateFormat format2 = new SimpleDateFormat("MM");
    month = Integer.valueOf(format2.format(dt1));
} catch (Exception ex) {
    month = new Integer(-1);
...
intgetMonth(String name)

Returns the month number from a given month name.

if (isEmptyString(name)) {
    throw new IllegalArgumentException("Name is null!");
name = name.trim().toLowerCase();
final String[] months = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov",
        "dec" };
for (int i = 0; i < months.length; i++) {
    if (name.startsWith(months[i])) {
...
intgetMonth(String pFormattedDate)
get Month
StringTokenizer vSt = new StringTokenizer(pFormattedDate, "-");
vSt.nextToken();
int val = Integer.parseInt(vSt.nextToken());
return val;
StringgetMonth(String quarters)
get Month
String month;
int m = Integer.parseInt(quarters);
m = m * 3 - 2;
if (m > 0 && m < 10) {
    month = "0" + String.valueOf(m);
} else {
    month = String.valueOf(m);
return month;
StringgetMonth(String sMonth)
get Month
String sMonthLC = sMonth.toLowerCase();
if (sMonthLC.startsWith("jan") || sMonthLC.startsWith("ge"))
    return "01";
if (sMonthLC.startsWith("f"))
    return "02";
if (sMonthLC.startsWith("mar"))
    return "03";
if (sMonthLC.startsWith("ap"))
...
intgetMonth(String startTime)
get Month
int year = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
    year = sdf.parse(startTime).getMonth() + 1;
} catch (Exception ex) {
    ex.printStackTrace();
return year;
...
StringgetMonth(String str_date)
get Month
return getMonth(str_date, "-");
StringgetMonth(String strDate)
get Month
String month = "";
if (strDate != null && !strDate.equals("")) {
    strDate = strDate.trim();
    month = getElement(strDate.split("-"), 1);
if (!month.equals("") && month.length() > 1) {
    if (month.substring(0, 1).equals("0")) {
        month = month.substring(1, month.length());
...
intgetMonth(String strDate)
get Month
Calendar cale = toCalendar(strDate);
if (cale == null) {
    return -1;
return cale.get(Calendar.MONTH) + 1;