Java Utililty Methods Year Format

List of utility methods to do Year Format

Description

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

Method

intgetYear(String pFormattedDate)
get Year
StringTokenizer vSt = new StringTokenizer(pFormattedDate, "-");
int val = Integer.parseInt(vSt.nextToken());
return val;
StringgetYYMMDD()
get YYMMDD
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
return sdf.format(d);
StringgetYYMMDD(int i)
get YYMMDD
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, i);
date = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyMMdd:hhmm");
return df.format(date);
StringgetYYYY()
get YYYY
return formatterYYYY.format(Calendar.getInstance().getTime());
StringgetYYYY(java.util.Date date)
get YYYY
if (date == null)
    return "";
return yyyy.format(date);
Stringgetyyyy_MM_dd(Date date)
getyyyMdd
if (date == null)
    return "";
return sdf.format(date);
Stringgetyyyy_MM_dd2(String date)
getyyyMdd
if (date == null)
    return "";
return sdf.format(sdf.parse(date));
SimpleDateFormatgetYYYYMM()
get YYYYMM
SimpleDateFormat yyyymm = new SimpleDateFormat("yyyyMM");
return yyyymm;
StringgetYYYYMM(final Date date, final String separator)
Returns the date as month/day/year with the supplied separator.
SimpleDateFormat format = new SimpleDateFormat("yyyy" + separator + "MM");
return format.format(date);
StringgetYYYYMMDD(Date date)
get YYYYMMDD
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
return sdf.format(date);