Java Timestamp to String toStringFormatGMTTime(Timestamp time, String format)

Here you can find the source of toStringFormatGMTTime(Timestamp time, String format)

Description

to String Format GMT Time

License

Open Source License

Declaration

public static String toStringFormatGMTTime(Timestamp time, String format) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;
import java.text.*;

import java.util.TimeZone;

public class Main {
    public static String toStringFormatGMTTime(Timestamp time, String format) {

        if (time == null) {
            return null;
        }//from  w ww  .ja v  a 2  s  .  co m

        return toStringFormatGMTTime(time.getTime(), format);
    }

    public static String toStringFormatGMTTime(long time, String format) {

        SimpleDateFormat sdf = new SimpleDateFormat(format);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

        return sdf.format(new java.util.Date(time));
    }
}

Related

  1. timestampToString(Timestamp ts, Calendar cal)
  2. timestampToStringFF(Timestamp date)
  3. timestampToUTC(Timestamp marcTimestamp)
  4. toString(Timestamp t, String precision)
  5. toString(Timestamp value)