我想通过 DateTime 类获取当前日期和时间,我从http://sourceforge.net/projects/joda-time/files/joda-time/下载了 Joda
我将提取文件夹中的三个 jar 文件添加到我的项目属性的 java 构建路径中。我的代码类似于以下代码:
import org.joda.time.DateTime;
public class TappedNFC extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tapped_nfc);
Button BeamButton=(Button)findViewById(R.id.BeamButton);
BeamButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DateTime dt = new DateTime();
int month = dt.getMonthOfYear();
TextView tx=(TextView)findViewById(R.id.textView1);
tx.setText(Integer.toString(month));
}
});
}
但logcat得到异常:
03-04 14:57:18.309: E/AndroidRuntime(540): FATAL EXCEPTION: main
03-04 14:57:18.309: E/AndroidRuntime(540): java.lang.NoClassDefFoundError: org.joda.time.DateTime
03-04 14:57:18.309: E/AndroidRuntime(540): at com.example.tappednfc.TappedNFC$1.onClick(TappedNFC.java:28)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.view.View.performClick(View.java:3460)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.view.View$PerformClick.run(View.java:13955)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Handler.handleCallback(Handler.java:605)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Handler.dispatchMessage(Handler.java:92)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.os.Looper.loop(Looper.java:137)
03-04 14:57:18.309: E/AndroidRuntime(540): at android.app.ActivityThread.main(ActivityThread.java:4340)
03-04 14:57:18.309: E/AndroidRuntime(540): at java.lang.reflect.Method.invokeNative(Native Method)
03-04 14:57:18.309: E/AndroidRuntime(540): at java.lang.reflect.Method.invoke(Method.java:511)
03-04 14:57:18.309: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-04 14:57:18.309: E/AndroidRuntime(540): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-04 14:57:18.309: E/AndroidRuntime(540): at dalvik.system.NativeStart.main(Native Method)
我以前没用过Joda,所以请帮我解决这个问题。非常感谢。