Java Timestamp Create getTimestampString(long timeInMillis)

Here you can find the source of getTimestampString(long timeInMillis)

Description

get Timestamp String

License

Open Source License

Declaration

static public String getTimestampString(long timeInMillis) 

Method Source Code


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

import java.sql.Timestamp;

public class Main {
    static public String getTimestampString(long timeInMillis) {
        Timestamp ts = new Timestamp(timeInMillis);
        String tsStr = ts.toString().substring(0, 19) + "-0" + ts.getTimezoneOffset() / 60 + "00";
        /*//from   ww  w.ja va 2 s. c  om
        System.out.println("toGMTString = " + ts.toGMTString());
        System.out.println("toLocaleString = " + ts.toLocaleString());
        System.out.println("toString = " + ts.toString());
        System.out.println("timezoneOffSet = " + ts.getTimezoneOffset());
        System.out.println("returned string = " + tsStr);   
        */
        return tsStr;
    }
}

Related

  1. getTimestampLexical(boolean showSeconds, Locale locale)
  2. getTimestampMinusDays(Integer days)
  3. getTimestampNullSafe(final Date ts)
  4. getTimestampOrNull(Object dbResult)
  5. getTimeStampString()
  6. getTimeStampStringFormat(Timestamp ts, String fmt)
  7. getTimestampToOracle()
  8. getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate)
  9. getTimeStrByTimestamp(long timestamp, String tz)