Example usage for android.util TimeFormatException printStackTrace

List of usage examples for android.util TimeFormatException printStackTrace

Introduction

In this page you can find the example usage for android.util TimeFormatException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.snaptic.api.SnapticAPI.java

private long parse3339(String time) {
    if (time == null || time.length() == 0) {
        return 0;
    }/*  www  .  j  a v a2  s. c om*/

    if (timestamper != null) {
        try {
            timestamper.parse3339(time);
        } catch (TimeFormatException e) {
            log("caught a TimeFormatException parsing timestamp: \"" + time + '"');
            e.printStackTrace();
            return 0;
        }

        return timestamper.normalize(false);
    } else {
        Date timestamp = new Date();

        SimpleDateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        rfc3339.setLenient(true);

        try {
            timestamp = rfc3339.parse(time);
        } catch (ParseException e) {
            log("caught a ParseException parsing timestamp: \"" + time + '"');
            e.printStackTrace();
            return 0;
        }

        return timestamp.getTime();
    }
}