我使用属性将jar lib导入到android项目中并添加了jar lib。我在编译时没有出错,但我“不幸的是,iDate已经停止了”。在android上运行项目之后。这是我的代码。请帮助找到共鸣。
package com.hasibul.idate;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Gravity;
import android.widget.EditText;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.joda.time.DateTime;
import org.joda.time.chrono.IslamicChronology;
public class MainActivity extends Activity
{
private EditText lbl1,lbl2,lbl3;
private IslamicDateConverter islamicDateConverter;
/** Called when the activity is first created.
* @param savedInstanceState */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lbl1 = (EditText)findViewById(R.id.label1);
lbl1.setGravity(Gravity.CENTER);
lbl2 = (EditText)findViewById(R.id.label2);
lbl2.setGravity(Gravity.CENTER);
lbl3 = (EditText)findViewById(R.id.label3);
lbl3.setGravity(Gravity.CENTER);
//islamic date maker
islamicDateConverter = new IslamicDateConverter();
//get current time
long millisec = System.currentTimeMillis();
//start the timer and wait for one second
new CountDownTimer(millisec, 1000) {
private final Date today = new Date();
private final SimpleDateFormat engTime = new SimpleDateFormat("hh:mm:ss a");
private final SimpleDateFormat engdate = new SimpleDateFormat("EE dd MMM yyyy");
private final DateTime dateTme = new DateTime(today);
private final DateTime islamicDate = dateTme.withChronology(IslamicChronology.getInstance());
private String todayEngTime;
private final String todayEngDate = engdate.format(today);
private final String month = islamicDateConverter.getMonthName(islamicDate.getMonthOfYear());
private final String day = islamicDateConverter.getDayName(islamicDate.getDayOfWeek());
private final int week = islamicDate.getDayOfMonth();
private final int year = islamicDate.getYear();
@Override
public void onTick(long l) {
todayEngTime = engTime.format(new Date());
lbl1.setText(todayEngDate);
lbl2.setText(todayEngTime);
lbl3.setText(day+" "+week+" "+month+" "+year);
}
@Override
public void onFinish() {
//never finish
}
}.start();
}
}