Java Timestamp Field getDateTimeStr(Timestamp timestamp)

Here you can find the source of getDateTimeStr(Timestamp timestamp)

Description

get Date Time Str

License

Open Source License

Declaration

public static final String getDateTimeStr(Timestamp timestamp) 

Method Source Code


//package com.java2s;

import java.sql.Timestamp;

import java.util.Calendar;

public class Main {
    public static final String getDateTimeStr(Timestamp timestamp) {
        if (timestamp == null) {
            return null;
        }//from www  . j  a  v a  2 s  .c o m
        Calendar cal = Calendar.getInstance();
        cal.setTime(timestamp);
        return cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR)
                + " " + getFixedTwoStr(cal.get(Calendar.HOUR_OF_DAY)) + ":"
                + getFixedTwoStr(cal.get(Calendar.MINUTE));
    }

    public static String getFixedTwoStr(int i) {
        String fixedTwoStr = i + "";
        if (i < 10) {
            fixedTwoStr = "0" + i;
        }
        return fixedTwoStr;
    }
}

Related

  1. getDateTime(Timestamp argRenDt)
  2. getDateTime(Timestamp timestamp)
  3. getDateTimeFromSqlTimestamp(Timestamp timestamp)
  4. getDateTimeFromTimeStamp(Timestamp timestamp)
  5. getDateTimestamp(ResultSet rs, String columnLabel)
  6. getDateTimeString(java.sql.Timestamp ts)
  7. getDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end)
  8. getDayEnd(java.sql.Timestamp stamp, int daysLater)
  9. getDayOfMonthBy(Timestamp ts)