Java Utililty Methods SQL Date Format

List of utility methods to do SQL Date Format

Description

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

Method

StringformatDateTd(Object obj)
format Date Td
String out = "<td style='text-align:center'>";
String strDate = formatDate(obj);
if (strDate.length() == 0) {
    out = (new StringBuilder()).append(out).append("&nbsp;").toString();
} else {
    out = (new StringBuilder()).append(out).append(strDate).toString();
out = (new StringBuilder()).append(out).append("</td>").toString();
...
DateformatDateToCustfmt(java.util.Date date, String dateFmt)
format Date To Custfmt
if (date == null) {
    return null;
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(dateFmt);
return java.sql.Date.valueOf(dateFormat.format(date));
StringformatDurationMillisToString(long millis)
format Duration Millis To String
return formatMillisToString(millis, DURATION_PATTERN);
StringformatFloat(int floatValue)
formatFloat Convert a float (java.sql.Float) representation into string.
return (new Float(floatValue).toString());
StringformatLogParam(Array obj)
Formatter for debugging purposes only.
String result = "";
try {
    result = "(array of type" + obj.getBaseTypeName().length() + ")";
} catch (SQLException e) {
    result = "(array of unknown type)";
return result;
StringformatNumberWithZeroPrefix(int numOfZero, Integer value)
formatNumberWithZeroPrefix Convert a integer (java.sql.Integer) representation into string with Zeros prefix.
return (formatNumberWithZeroPrefix(numOfZero, value, false));
StringformatSQLError(SQLException e)
Formats the specified the SQL exception object displaying the error message, error code and the SQL state code.
if (e == null) {
    return "";
StringBuilder sb = new StringBuilder();
sb.append(e.getMessage());
sb.append("\nError Code: " + e.getErrorCode());
String state = e.getSQLState();
if (state != null) {
...
StringBuilderformatSqlException(StringBuilder errorMessage, SQLException exception)
format Sql Exception
final String sqlState = exception.getSQLState();
final int errorCode = exception.getErrorCode();
final String message = exception.getMessage();
return errorMessage.append("SQLState: ").append(sqlState).append(" ErrorCode: ").append(errorCode)
        .append(" Message: ").append(message);
StringformatSQLForColumnName(Connection conn, String strSQL)
format SQL For Column Name
String method = "formatSQLForColumnName";
int location = 1000;
try {
    location = 2000;
    Statement stmt = conn.createStatement();
    location = 2100;
    ResultSet rs = stmt.executeQuery(strSQL);
    location = 2200;
...