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

Stringformat(final int iDay, final int iMonth, final int iYear)
Format the given day, month and year ( in ISO format )
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_ISO_FORMAT);
return dateFormat.format(getUtilDate(iDay, iMonth, iYear));
Stringformat(String day, String month, String year, Locale locale)
this method parses the @params String day,month,year to ints, builds a Gregorian Calendar with these values to get the corresponding Date that is returned as String by invoking the method format(Date d,Locale locale), that used to parse a Date to a String.
int tag = Integer.parseInt(day);
int monat = Integer.parseInt(month);
int jahr = Integer.parseInt(year);
Calendar cal = new GregorianCalendar(jahr, monat - 1, tag);
Date d = cal.getTime();
return format(d, locale);
Stringformat2yyyyMMdd(Date date)
formatyyyy M Mdd
if (null == date) {
    return null;
return new SimpleDateFormat(yyyyMMdd).format(date);
Stringformat_D_MM_YYYY_HH_MM(Date date)
convierte date en su representacion texto en formato d/MM/yyyy HH:mm
return SDF_D_MM_YYYY_HH_MM.format(date);
StringformateDate2yyyyMMdd()
formate Dateyyyy M Mdd
return formateCurrentDate2String(YYYYMMDD);
StringformatInyyyyMMdd(java.util.Date date)
getCurrentDayInyyyyMMdd: returns the current day.
if (date != null) {
    return new SimpleDateFormat("yyyyMMdd").format(date);
} else {
    return null;
StringformatMdDdYySlashed(Date date)
Formats a date object to "MM/dd/yy".
if (date == null) {
    return "";
return formatSlashedMmDdYy().format(date);
StringformatMmDdYyyy(final Date date)
format the given date as: "MM/dd/yyyy".
SimpleDateFormat sdf = new SimpleDateFormat(MM_DD_YYYY_DATE_FORMAT_STRING);
return sdf.format(date);
StringformatMonth(int timeInfo, String yearInfo)
format Month
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.MONTH, timeInfo - 1);
cal.set(Calendar.YEAR, Integer.parseInt(yearInfo));
SimpleDateFormat formatter = new SimpleDateFormat("MMM-yyyy");
return formatter.format(cal.getTime());
StringformatNanosYearGMT(long nanos)
format Nanos Year GMT
long millis = nanos / 1000000;
Date d = new Date(millis);
synchronized (GMT_FORMAT_MILLIS_NO_Z) {
    return GMT_FORMAT_YEAR_NO_Z.format(d);