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

StringtoYYYYMMDD(Calendar cal)
to YYYYMMDD
return sdf.format(cal.getTime());
DatetoYyyyMMddToDate(String date)
to Yyyy M Mdd To Date
return yyyyMMdd.parse(date);
DateunmarshalYYYYMMDD(String date)
unmarshal YYYYMMDD
try {
    return dfYYYYMMDD.parse(date);
} catch (ParseException ex) {
    ex.printStackTrace();
    return null;
StringyyyyMMdd(Date date)
yyyy M Mdd
return dateFormat4yyyyMMdd().format(date);
StringyyyyMMdd(Date date)
yyyy M Mdd
return getDateFormat(b).format(date);
StringyyyymmddFormat(Date date)
yyyymmdd Format
SimpleDateFormat yyyymmddFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
return yyyymmddFormat.format(date);
SimpleDateFormatyyyyMMddFormatter()
yyyy M Mdd Formatter
return new SimpleDateFormat("yyyyMMdd");
DateyyyyMMddHHmmss2date(String str)
yyyy M Mdd H Hmmssdate
DateFormat format = new SimpleDateFormat(yyyyMMddHHmmss);
Date date = new Date();
try {
    date = format.parse(str);
} catch (ParseException e) {
    e.printStackTrace();
return date;
...
DateyyyyMMddStringToDate(String date)
yyyy M Mdd String To Date
return new SimpleDateFormat("yyyy.MM.dd").parse(date);