get Date from Bundle - Android Android OS

Android examples for Android OS:Bundle Get

Description

get Date from Bundle

Demo Code


//package com.book2s;
import android.os.Bundle;
import java.util.Date;

public class Main {
    private static final long INVALID_BUNDLE_MILLISECONDS = Long.MIN_VALUE;

    public static Date getDate(Bundle bundle, String key) {
        if (bundle == null) {
            return null;
        }/*from  ww w.  j  a  v a  2  s .  c  o  m*/

        long n = bundle.getLong(key, INVALID_BUNDLE_MILLISECONDS);
        if (n == INVALID_BUNDLE_MILLISECONDS) {
            return null;
        }

        return new Date(n);
    }
}

Related Tutorials