Java Utililty Methods SQL Time Format

List of utility methods to do SQL Time Format

Description

The list of methods to do SQL Time Format are organized into topic(s).

Method

DateformatCharDateYMD(String str)
format Char Date YMD
return formatCharDateYMD(str, DEFAULT_DATE_YMD_FORMAT);
DateformatCharDateYMDHMS(String str)
format Char Date YMDHMS
String format = DEFAULT_YMDHMSDATE_FORMAT;
if (str == null || str.trim().length() == 0) {
    return null;
SimpleDateFormat sdf = new SimpleDateFormat(format);
ParsePosition pos = new ParsePosition(0);
java.util.Date date = sdf.parse(str, pos);
if (date == null) {
...
StringformatDate(String Format)
format Date
java.util.Date d = Calendar.getInstance().getTime();
try {
    SimpleDateFormat f = new SimpleDateFormat(Format);
    return f.format(d);
} catch (Exception e) {
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
    return f.format(d);
StringformatDateWithSlashes(java.sql.Date date)
Formatier Datum mit "/" getrennt
if (date != null) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(date.getTime());
    String s = "";
    int iMonat = cal.get(Calendar.MONTH) + 1;
    s = cal.get(Calendar.DAY_OF_MONTH) + "/" + iMonat + "/" + cal.get(Calendar.YEAR);
    return s;
} else {
...
StringformatDateYM(Date date, String datePtn)
format Date YM
if (date == null) {
    return null;
return toString(date, getYMFormat(datePtn));
StringformatDateYMD(String str, String datePtn)
format Date YMD
if (str == null || str.trim().length() == 0) {
    return null;
return toYMD(formatCharDateYMD(str), datePtn);
StringformatDefaultValue(Object o)
Converts the object into a DEFAULT clause value.
Class<?> objectClass = o.getClass();
String value = null;
if (Number.class.isAssignableFrom(objectClass)) {
    return ((Number) o).toString();
} else if (Boolean.class.isAssignableFrom(objectClass)) {
    return o.toString();
} else if (java.sql.Date.class.isAssignableFrom(objectClass)) {
    value = new SimpleDateFormat("yyyy-MM-dd").format((Date) o);
...
StringformatExceptionForToolsWithLimitedCharacterSet(String exceptionLabel)
Some tools don't allow for special characters in their monitoring labels.
if (exceptionLabel == null) {
    return null;
return exceptionLabel.replace(",ErrorCode=", ".ErrorCode ").replace(",SQLState=", "-SQLState ");
TimeformatTime(Date date)
format Time
Time time = new Time(date.getTime());
return time;
StringformatTime(final Time time)
Format time.
return formatDate(time, "hh:mm");