Here you can find the source of getTimestampAsString(Timestamp tsTimestamp)
Parameter | Description |
---|---|
tsTimestamp | - timestamp to convert |
public static String getTimestampAsString(Timestamp tsTimestamp)
//package com.java2s; /*/* ww w .j a v a2 s . c o m*/ * Copyright (C) 2003 - 2013 OpenSubsystems.com/net/org and its owners. All rights reserved. * * This file is part of OpenSubsystems. * * OpenSubsystems is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.sql.Timestamp; public class Main { /** * Separator we used to separate time from the nanosecond portion of the * timestamp when converted to string. */ public static final char NANO_SEPARATOR = ':'; /** * Convert timestamp to string including it's nanosecond portion so that it * can be safely stored in variable of web page. * * @param tsTimestamp - timestamp to convert * @return String - text containing time and nanosecond portion of timestamp */ public static String getTimestampAsString(Timestamp tsTimestamp) { StringBuilder sbTimestamp = new StringBuilder(); sbTimestamp.append(tsTimestamp.getTime()); sbTimestamp.append(NANO_SEPARATOR); sbTimestamp.append(tsTimestamp.getNanos()); return sbTimestamp.toString(); } }