twitter Date To Timestamp - Android java.util

Android examples for java.util:Date Timestamp

Description

twitter Date To Timestamp

Demo Code


//package com.java2s;
import android.util.Log;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    private static DateFormat _dateFormatter = new SimpleDateFormat(
            "EEE MMM dd HH:mm:ss Z yyyy");

    public static Long twitterDateToTimestamp(String twitterDate) {
        Long timestamp = null;// w  w  w.  ja  v a  2  s. com
        try {
            _dateFormatter.setTimeZone(TimeZone.getDefault());
            Date date = (Date) _dateFormatter.parse(twitterDate);
            timestamp = date.getTime() - 1070000L;
        } catch (ParseException parseException) {
            Log.e("TimeHelper", "Unable to parse time: " + twitterDate);
        }

        return timestamp;
    }
}

Related Tutorials