views:

156

answers:

1

Has anybody used jodatime with android? I'm getting a force close with no trace.

package test.journal.help;

import java.util.Date;

import org.joda.time.DateTime;
import org.joda.time.Days;

import android.app.Activity;
import android.os.Bundle;
public class journaltester extends Activity {
    /** Called when the activity is first created. */

    private Date today = new Date();

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      Days days = Days.daysBetween(new DateTime(today), new DateTime(today));
        setContentView(R.layout.main);

    }
}

Value of today : "Sat Aug 07 00:00:00 America/New_York 2010"

alright making some progress... getting a stackoverflow error at org.joda.time.DateTimeZone.getDefault() according to kiwidoc this is caused if zone is null.

 public static DateTimeZone getDefault() {
    DateTimeZone zone = cDefault;
    if (zone == null) {
        synchronized(DateTimeZone.class) {
            zone = cDefault;
            if (zone == null) {
                DateTimeZone temp = null;
                try {
                    try {
                        temp = forID(System.getProperty("user.timezone"));
                    } catch (RuntimeException ex) {
                        // ignored
                    }
                    if (temp == null) {
                        temp = forTimeZone(TimeZone.getDefault());
                    }
                } catch (IllegalArgumentException ex) {
                    // ignored
                }
                if (temp == null) {
                    temp = UTC;
                }
                cDefault = zone = temp;
            }
        } //LINE 147
    }
    return zone;
}

Heres the stack:

Thread [<3> main] (Suspended (exception StackOverflowError))    
DateTimeZone.getDefault() line: 147 
ISOChronology.getInstance() line: 86    
DateTimeUtils.getChronology(Chronology) line: 231   
DateConverter(AbstractConverter).getChronology(Object, Chronology) line: 82 
DateTime(BaseDateTime).<init>(Object, Chronology) line: 170 
DateTime.<init>(Object) line: 168   
PlantsCursorAdapter.newView(Context, Cursor, ViewGroup) line: 71    
PlantsCursorAdapter(CursorAdapter).getView(int, View, ViewGroup) line: 182  
+1  A: 

This occurs because user.timezone system property is null. See http://sourceforge.net/tracker/?func=detail&amp;aid=3056104&amp;group_id=97367&amp;atid=617889

JodaStephen