Here you can find the source of Timestamp2UTC(Timestamp mytime)
Parameter | Description |
---|---|
mytime | input timestamp |
public static String Timestamp2UTC(Timestamp mytime)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.TimeZone; public class Main { /**//from w w w . j ava 2 s. c o m * Converts a java.util.Timestamp to UTC * needed if the "Generalized Time Syntax Plug-in" of FedoraDS is not enabled * @param mytime input timestamp * @return UTC SQL timestamp */ public static String Timestamp2UTC(Timestamp mytime) { Timestamp b = new Timestamp(mytime.getTime()); SimpleDateFormat mySimpleFormat = new SimpleDateFormat("yyyyMMddHHmmss"); mySimpleFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String ret = mySimpleFormat.format(b) + "Z"; return ret; } }