Java Utililty Methods yyyy

List of utility methods to do yyyy

Description

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

Method

StringformatDateFromStringToString(String str)
format Date From String To String
SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sf2 = new SimpleDateFormat("yyyy-MM-dd");
try {
    return sf2.format(sf1.parse(str));
} catch (ParseException e) {
    return "";
StringformatDateNoTime(Date date)
Formats a date as (for example) "2/6/2002".
return dateFormatter2.format(date);
StringformatDateString(java.util.Date date, String format)
Convert a date to required String format.
if ((date == null) || (format == null)) {
    return null;
SimpleDateFormat fm = new SimpleDateFormat(format);
return fm.format(date);
StringformatDateToString(Date d)
formatage d'une date pour ne garder que jour, mois , annee
if (d != null) {
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    return dateFormat.format(d);
} else {
    return null;
DateformatDateToString(String strDate)
format Date To String
Date date = null;
try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    date = sdf.parse(strDate);
} catch (Exception e) {
    date = new Date();
return date;
...
StringformatDicomDate(String dicomDate)
Format a DICOM date (YYYYMMDD) to a more human readable form.
if ((dicomDate == null) || (dicomDate.length() != 8) || (dicomDate.replaceAll("[0-9]", "").length() != 0)) {
    return dicomDate;
Date date = null;
try {
    date = DICOM_DATE_FORMAT.parse(dicomDate);
    return HUMAN_DATE_FORMAT.format(date);
} catch (ParseException e) {
...
StringformatearDateToString(Date date)
Metodo realiza formato dd/MM/yyyy a un objeto Date
SimpleDateFormat sdf = new SimpleDateFormat(FECHA_FORMATO);
return date != null ? sdf.format(date) : null;
StringformatFecha(Date fecha)
format Fecha
SimpleDateFormat sdf = new SimpleDateFormat(PATRON_FECHA);
return sdf.format(fecha);
StringformatFromDate(Date date)
format From Date
return formatFromDate(FORMATER_YYYY_MM_DD, date);
StringformatG(Date date)
format G
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_STYLE_G);
if (null != date && !"".equals(date)) {
    return sdf.format(date);
return null;