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 tempdat, Locale locale)
This method parses the @param String tempdat, according to a specified format style determined by the @param Locale locale to a Date.
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, locale);
Date d = df.parse(tempdat, new ParsePosition(0));
Calendar cal_date = new GregorianCalendar();
cal_date.setTime(d);
int monat = 0;
monat = cal_date.get(Calendar.MONTH) + 1;
String monatstr = String.valueOf(monat);
return monatstr;
...
DategetMonth1D()
get Month D
return getMonth1D(new Date());
StringgetMonthAdd(String operateDate, int flag)
get Month Add
if (operateDate.length() == 7) {
    operateDate = operateDate + "-01";
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c1 = Calendar.getInstance();
c1.setTime(sdf.parse(operateDate));
c1.add(Calendar.MONTH, flag);
return sdf.format(c1.getTime()).substring(0, 7);
...
StringgetMonthAndDate()
get Month And Date
return mmDDDateFmt.format(new Date());
StringgetMonthBefore(Date d, int number)
get Month Before
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, number);
calendar.add(Calendar.DAY_OF_MONTH, -1);
return formatter.format(calendar.getTime());
StringgetMonthBegin(String strdate)
get Month Begin
Date date = parseDate(strdate);
return format(addDate(null, 0), "yyyy-MM") + "-01";
StringgetMonthBegin(String strdate)
get Month Begin
java.util.Date date = parseDate(strdate);
return format(date, "yyyy-MM") + "-01";
DategetMonthByNow(int month)
get Month By Now
SimpleDateFormat simpleDateFormatMM = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.MONTH, month);
Date mb = c.getTime();
String mon = simpleDateFormatMM.format(mb);
StringBuffer stringBuffer = new StringBuffer();
...
intgetMonthCount(String from, String to)
get Month Count
return getMonthCount(from, to, DATE_FORMAT.toPattern());
StringgetMonthDesc(Date month)
This method is used for getting month description
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("MM");
return sdf.format(month).toUpperCase();