Java SQL Date Format formatDateTd(Object obj)

Here you can find the source of formatDateTd(Object obj)

Description

format Date Td

License

Open Source License

Declaration

public static String formatDateTd(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.sql.Date;

public class Main {
    public static String formatDateTd(Object obj) {
        String out = "<td style='text-align:center'>";
        String strDate = formatDate(obj);
        if (strDate.length() == 0) {
            out = (new StringBuilder()).append(out).append("&nbsp;").toString();
        } else {/*from www  .java 2  s  . co m*/
            out = (new StringBuilder()).append(out).append(strDate).toString();
        }
        out = (new StringBuilder()).append(out).append("</td>").toString();
        return out;
    }

    public static String formatDate(Object obj) {
        String out = "";
        if (obj == null) {
            return out;
        }
        try {
            Date dateval = (Date) obj;
            if (dateval != null) {
                SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy");
                dateformat.setLenient(false);
                out = dateformat.format(dateval);
            }
        } catch (Exception e) {
            out = (new StringBuilder()).append("bad date in FormatUtils.formatDate: ").append(obj.toString())
                    .append(" error: ").append(e.getMessage()).toString();
        }
        return out;
    }
}

Related

  1. formatAsText(ResultSet result_set, PrintWriter out)
  2. formatBytableCols(Object[] obj, String[] tableCols)
  3. formatDate(java.util.Date uDate)
  4. formatDate(Object obj)
  5. formatDate(String date)
  6. formatDateToCustfmt(java.util.Date date, String dateFmt)
  7. formatDurationMillisToString(long millis)
  8. formatFloat(int floatValue)
  9. formatLogParam(Array obj)