Here you can find the source of stringToTimestamp(String ts)
Parameter | Description |
---|---|
ts | the string |
public static Timestamp stringToTimestamp(String ts)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012-2015 INRIA.//from w w w. java2 s. c om * 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: * Generoso Pagano - initial API and implementation ******************************************************************************/ import java.sql.Timestamp; public class Main { /** * Conversion setting to 0 the nanoseconds, * to deal with a mysql driver bug: * nanoseconds value is not correct. * e.g. if the string does not contains nanoseconds * a non deterministic value is used for nanoseconds. * * @param ts the string * @return the timestamp */ public static Timestamp stringToTimestamp(String ts) { Timestamp t = Timestamp.valueOf(ts); t.setNanos(0); return t; } }