Java SQL Date Format formatDate(Object obj)

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

Description

format Date

License

Open Source License

Declaration

public static String formatDate(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 formatDate(Object obj) {
        String out = "";
        if (obj == null) {
            return out;
        }//from   w  w  w . j  av  a2 s.  c o m
        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. dateFromLong(Long longObject)
  2. formataData(Date data)
  3. formatAsText(ResultSet result_set, PrintWriter out)
  4. formatBytableCols(Object[] obj, String[] tableCols)
  5. formatDate(java.util.Date uDate)
  6. formatDate(String date)
  7. formatDateTd(Object obj)
  8. formatDateToCustfmt(java.util.Date date, String dateFmt)
  9. formatDurationMillisToString(long millis)