Java Timestamp Parse parseSQLiteTimestamp(String dd)

Here you can find the source of parseSQLiteTimestamp(String dd)

Description

parse SQ Lite Timestamp

License

Open Source License

Declaration

public static Timestamp parseSQLiteTimestamp(String dd) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Cai Bowen, Zhou Liangpeng.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * /*  w w w .ja  v a 2s.c  om*/
 * Contributors:
 *     Cai Bowen,  Zhou Liangpeng. - initial API and implementation
 ******************************************************************************/

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

public class Main {
    public static final SimpleDateFormat SQLITE_DATE_FMT = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS");

    public static Timestamp parseSQLiteTimestamp(String dd) {
        try {
            return new Timestamp(SQLITE_DATE_FMT.parse(dd).getTime());
        } catch (Exception e) {
            return new Timestamp(System.currentTimeMillis());
        }
    }
}

Related

  1. parse(java.sql.Timestamp timestamp)
  2. parseAsCassandraTimestamp(String dateString)
  3. parseDateTimeToTimestamp(String string)
  4. parseHeaderDate(String timestamp)
  5. parseSnapshotTimestamp(final String tstamp)
  6. parseStopTime(String timestamp, String timezone)
  7. parseTimestamp(Date date)
  8. parseTimestamp(Date date)
  9. parseTimestamp(final String format, final String time)