Code example for Parcel

Methods: writeLong, writeString

0
    public int describeContents() { return 0; } 
 
    @Override 
    public void writeToParcel(Parcel dest, int flags) {
        // translate the Date to a long 
        dest.writeLong(
            (null == date)
            ? -1 
            : date.getTime());
         
        dest.writeString(
            (null == state)
            ? "" 
            : marshalState.get(state));
    } 
 
    @Override 
    public String toString() {
        return "SimpleParcelable{" + date + "," + state + "}";
    } 
}