Java Timestamp Format Timestamp2DDMMYYYY(java.sql.Timestamp ts)

Here you can find the source of Timestamp2DDMMYYYY(java.sql.Timestamp ts)

Description

Timestamp DDMMYYYY

License

Open Source License

Declaration

public static String Timestamp2DDMMYYYY(java.sql.Timestamp ts) 

Method Source Code

//package com.java2s;

public class Main {
    public static String Timestamp2DDMMYYYY(java.sql.Timestamp ts) {
        if (ts == null) {
            return "";
        } else {/* ww w .j av a 2  s  .  c o m*/
            java.util.Calendar calendar = java.util.Calendar.getInstance();
            calendar.setTime(new java.util.Date(ts.getTime()));

            String strTemp = Integer.toString(calendar.get(calendar.DAY_OF_MONTH));
            if (calendar.get(calendar.DAY_OF_MONTH) < 10) {
                strTemp = "0" + strTemp;
            }
            if (calendar.get(calendar.MONTH) + 1 < 10) {
                return strTemp + "/0" + (calendar.get(calendar.MONTH) + 1) + "/" + calendar.get(calendar.YEAR);
            } else {
                return strTemp + "/" + (calendar.get(calendar.MONTH) + 1) + "/" + calendar.get(calendar.YEAR);
            }
        }
    }
}

Related

  1. getTimestampFormat(long time)
  2. sortedTimestampFormat(Date date)
  3. stringConvertToTimestamp(String value, String format)
  4. TimeStamp2Date(long timestampString, String formats)
  5. timeStamp2Date(String seconds, String format)
  6. Timestamp2HHMMSS(java.sql.Timestamp ts, int iStyle)
  7. timestamp2String(long source, DateFormat format)
  8. Timestamp2UTC(Timestamp mytime)
  9. timestampConvertToString(int timeStamp, String format)