Android力量与JodaTime关闭

时间:2010-08-07 16:13:33

标签: java android jodatime

有没有人用过jodatime和android?我的力量很接近,没有任何痕迹。

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);

    }
}

今天的价值:“7月7日星期六00:00:00 America / New_York 2010”

好的取得一些进展...... 根据kiwidoc在org.joda.time.DateTimeZone.getDefault()中获取stackoverflow错误,如果zone为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;
}

继承人:

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 个答案:

答案 0 :(得分:2)