Java Timestamp to String timestampToUTC(Timestamp marcTimestamp)

Here you can find the source of timestampToUTC(Timestamp marcTimestamp)

Description

Convert a java.sql.Timestamp object (come from the database) to string in UTCdatetime format "yyyy-MM-dd'T'HH:mm:ssZ" format

License

Open Source License

Parameter

Parameter Description
marcTimestamp The Timestamp object

Return

The string value

Declaration

public static String timestampToUTC(Timestamp marcTimestamp) 

Method Source Code

//package com.java2s;
/**// www .  j a  v  a  2 s .c om
  * Copyright (c) 2009 University of Rochester
  *
  * This program is free software; you can redistribute it and/or modify it under the terms of the MIT/X11 license. The text of the  
  * license can be found at http://www.opensource.org/licenses/mit-license.php and copy of the license can be found on the project
  * website http://www.extensiblecatalog.org/. 
  *
  */

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

public class Main {
    /**
     * Convert a java.sql.Timestamp object (come from the database) to
     * string in UTCdatetime format "yyyy-MM-dd'T'HH:mm:ssZ" format
     * @param marcTimestamp The Timestamp object
     * @return The string value
     */
    public static String timestampToUTC(Timestamp marcTimestamp) {
        if (null == marcTimestamp) {
            return "no timestamp";
        } else {
            return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(marcTimestamp);
        }
    }
}

Related

  1. timestampToString(Timestamp timestamp)
  2. timestampToString(Timestamp timestamp, String pattern)
  3. timestampToString(Timestamp ts)
  4. timestampToString(Timestamp ts, Calendar cal)
  5. timestampToStringFF(Timestamp date)
  6. toString(Timestamp t, String precision)
  7. toString(Timestamp value)
  8. toStringFormatGMTTime(Timestamp time, String format)