Java Utililty Methods SQL Time Format

List of utility methods to do SQL Time Format

  1. HOME
  2. Java
  3. S
  4. SQL Time Format

Description

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

Method

Date formatCharDateYMD(String str)
format Char Date YMD
return formatCharDateYMD(str, DEFAULT_DATE_YMD_FORMAT);
Date formatCharDateYMDHMS(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) {
...
String formatDate(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);
String formatDateWithSlashes(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 {
...
String formatDateYM(Date date, String datePtn)
format Date YM
if (date == null) {
 return null;
return toString(date, getYMFormat(datePtn));
String formatDateYMD(String str, String datePtn)
format Date YMD
if (str == null || str.trim().length() == 0) {
 return null;
return toYMD(formatCharDateYMD(str), datePtn);
String formatDefaultValue(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);
...
String formatExceptionForToolsWithLimitedCharacterSet(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 ");
Time formatTime(Date date)
format Time
Time time = new Time(date.getTime());
return time;
String formatTime(final Time time)
Format time.
return formatDate(time, "hh:mm");


AltStyle によって変換されたページ (->オリジナル) /