如何在java中使用joda计时

如何在java中使用joda计时,java,jodatime,Java,Jodatime,目前我使用的是日历类型 GregorianCalendar gcalendar = new GregorianCalendar(); // Display current time and date information. System.out.print("Date: "); System.out.print(gcalendar.get(Calendar.MONTH)+1); //System.out.print(Calendar.MONTH); System.out.print(" "

目前我使用的是日历类型

GregorianCalendar gcalendar = new GregorianCalendar();
// Display current time and date information.

System.out.print("Date: ");
System.out.print(gcalendar.get(Calendar.MONTH)+1);
//System.out.print(Calendar.MONTH);
System.out.print(" " + gcalendar.get(Calendar.DATE) + " ");
System.out.println(year = gcalendar.get(Calendar.YEAR));

System.out.print("Time: ");
System.out.print(gcalendar.get(Calendar.HOUR_OF_DAY) + ":");
//System.out.print(Calendar.HOUR + ":");
System.out.print(gcalendar.get(Calendar.MINUTE) + ":");
System.out.println(gcalendar.get(Calendar.SECOND));
我想用乔达计时。。。
我该怎么办?

您没有说明在何种情况下您将使用Joda时间库,但在中说明了基础知识

您还可以参考如何使用Joda Time
年表
,这是该库背后的关键概念之一(我强烈建议您阅读以掌握基础知识)。下面是一个使用公历的示例:

DateTimeZone=DateTimeZone.forID(“欧洲/伦敦”);
年代学gregorian=GregorianChrology.getInstance(区域);
//当前时间与格里高利年表
DateTime dt=新的日期时间(公历);
int month=dt.getMonthOfYear();//获取当前的公历月份
int year=dt.getYear();//获取当前的公历年
int day=dt.getDayOfMonth()//获取当前的公历日
// ...

请阅读……如果您想使用Joda Time,请使用Joda Time——事实上,它比
日历
API好得多。阅读文档-它非常简单。我建议使用
DateFormatter
而不是所有这些手工格式化。(你真的想要8:7:5而不是08:07:05这样的时间吗?)