Android Date String Parse ISO8601ToTimestamp(String aDate)

Here you can find the source of ISO8601ToTimestamp(String aDate)

Description

ISO To Timestamp

License

Apache License

Declaration

public static long ISO8601ToTimestamp(String aDate) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static long ISO8601ToTimestamp(String aDate) {
        long result = 0;
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ssZ");
        try {// www.j a va2 s. c  o m
            result = new Timestamp(format.parse(aDate).getTime()).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return result;
    }

    public static long parse(String aFormat, String date) {
        SimpleDateFormat format = new SimpleDateFormat(aFormat);
        try {
            return format.parse(date).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

Related

  1. ParseStringToDate(String date)
  2. getDateByTime(String time)
  3. isDateString(String dirtyDate)
  4. isDateTimeString(String dirtyDateTime)