Java Timestamp Convert To timestamp2Internal(java.sql.Timestamp t)

Here you can find the source of timestamp2Internal(java.sql.Timestamp t)

Description

Converts a Timestamp into the internal encoding as defined above.

License

Open Source License

Parameter

Parameter Description
t a parameter

Return

non null string following the encoding defined above.

Declaration

public static String timestamp2Internal(java.sql.Timestamp t) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from w ww.ja v a 2 s  .  c  om*/
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Converts a Timestamp into the internal encoding as defined above.
     * @param t
     * @return non null string following the encoding defined above.
     * @since version_number
     * @author s3460
     */
    public static String timestamp2Internal(java.sql.Timestamp t) {
        if (t == null)
            return "";
        long seconds = t.getTime() / 1000; //miliseconds lost by division
        int nanos = t.getNanos(); //Timestamp stores nanos in own component

        return String.valueOf(seconds) // integral seconds
                + " " + String.valueOf(nanos); // nanoseconds
    }
}

Related

  1. convertToString(Timestamp dateData, String pattern, Locale locale)
  2. timestamp(Timestamp timestamp)
  3. Timestamp2Arch(Timestamp ts)
  4. timestamp2Calendar(Timestamp ts)
  5. timestamp2Date(java.sql.Timestamp t)
  6. timestamp2ToTimestamp(long seconds, int fraction, int width)
  7. timestampSqlToDate(Timestamp timestamp)
  8. TimestampToBigint(String timestamp)
  9. timeStampToBytes(Timestamp ts)