public static DateFormat getAlignedFormat ( ) { if ( DATE_FORMAT instanceof SimpleDateFormat ) { SimpleDateFormat sdf = ( SimpleDateFormat ) DATE_FORMAT ; String pattern = sdf . toPattern ( ) . replaceAll ( "M+" , "MM" ) . replaceAll ( "d+" , "dd" ) . replaceAll ( "h+" , "hh" ) . replaceAll ( "H+" , "HH" ) ; sdf . applyPattern ( pattern ) ; return sdf ; } else { return DATE_FORMAT ; } }
we need to take the pattern and modify it