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

DateFormatformatSlashedMmDdYy()
DateFormat for "MM/dd/yy".
return new SimpleDateFormat("MM/dd/yy");
StringformatTimeStampYearFirst(Date date)
format Time Stamp Year First
return date == null ? "" : dateTimeFormat2.format(date);
StringformatUniversalMonthYear(Date date)
format Universal Month Year
return UNIVERSAL_MONTH_YEAR_FORMAT.format(date);
StringformatYear(Date d, Locale locale)
format Year
SimpleDateFormat sdf = new SimpleDateFormat("yyyy", getSafeLocale(locale));
Calendar c = Calendar.getInstance(getSafeLocale(locale));
c.setTime(d);
return sdf.format(d);
StringformatYear(Date date)
Formats a Date object to an ISO8601 year string.
if (date == null) {
    return formatYear(new Date());
String dateStr = m_ISO8601Year.format(date);
return dateStr;
StringformatYear(Date date)
format Year
return format(date, DEFAULT_YEAR_FORMAT);
StringformatYearMonth(Date date)
format Year Month
try {
    return yyyyMM.format(date);
} catch (Exception ex) {
    ex.printStackTrace();
return null;
StringformatYyyyMm(Date date)
Formats a date object to "YYYYMM".
if (date == null) {
    return "";
return formatYyyyMm().format(date);
StringformatyyyyMMddHHmmss(long time)
formatyyyy M Mdd H Hmmss
return yyyyMMddHHmmss.format(new java.util.Date(time));
Stringget_Oracle_DateString_YYYYMMdd_HHmmss(java.util.Date date)
ge Oracl Date StrinYYYYM MdH Hmmss
if (date == null)
    return "NULL";
String dateString = "'" + YYYYMMdd_HHmmss.format(date) + "'";
return "TO_DATE(" + dateString + ", 'YYYY.MM.DD HH24:MI:SS')";