Android Date to Long Convert geLongFromString(final String date)

Here you can find the source of geLongFromString(final String date)

Description

ge Long From String

Declaration

public static long geLongFromString(final String date) 

Method Source Code

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.util.Log;

public class Main {
    public static long geLongFromString(final String date) {
        final Calendar calendar = getCalendarFromString(date);
        return calendar.getTimeInMillis();
    }//  w ww  . j  a  v a  2  s  .  c o m

    public static Calendar getCalendarFromString(final String date) {
        final SimpleDateFormat inputFormat = new SimpleDateFormat(
                "E, MMMM dd, yyyy");
        Date parsedDate = new Date();
        try {
            parsedDate = inputFormat.parse(date.trim());
        } catch (final ParseException e) {
            Log.e("DATE_PARSER",
                    "Error: Impossible to parse input string to calendar.",
                    e);
            throw new RuntimeException(e);
        }

        final Calendar currentDate = Calendar.getInstance();
        currentDate.setTime(parsedDate);

        return currentDate;
    }
}

Related

  1. parseDateToLong(String dateString)
  2. parseDateToLong2(String dateString)
  3. parseDateToLongString(String dateString)
  4. getTime(String dateString)
  5. dosToJavaTime(long dosTime)
  6. dosToJavaTme(int dosTime)
  7. getDateLong(Date date)