Android Timestamp String to Timestamp Convert serverTimestampToDate(String timestamp)

Here you can find the source of serverTimestampToDate(String timestamp)

Description

server Timestamp To Date

License

Open Source License

Declaration

public static Date serverTimestampToDate(String timestamp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    private static final String SERVER_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Date serverTimestampToDate(String timestamp) {
        try {//from   w  w  w  . j  a va2s  .  c om
            return new SimpleDateFormat(SERVER_DATE_FORMAT, Locale.GERMANY)
                    .parse(timestamp);
        } catch (ParseException e) {
            return new Date();
        }
    }
}

Related

  1. str2Timestamp(String str)
  2. stringConvertTimestamp(String time)