source on github
import java.util.Calendar;
import java.util.Locale;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
public class TestJodaTime {
public static void main(String[] args) {
System.out.println(new DateTime(Calendar.getInstance()));
System.out.println(new DateTime(Calendar.getInstance().getTime()));
System.out.println("*****************");
DateTime dt = DateTime.now();
System.out.println(dt);
System.out.println(dt.toDate());
System.out.println(dt.toCalendar(Locale.CHINA));
DateTime dt1 = dt.plusYears(1).plusDays(1).minusHours(1);
System.out.println(dt1);
System.out.println("----------------");
System.out.println(dt.getMonthOfYear());
System.out.println(dt.monthOfYear().getAsText());
System.out.println(dt.monthOfYear().getAsShortText(Locale.FRENCH));
System.out.println("================");
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
String str = fmt.print(dt);
System.out.println(str);
fmt = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss.SSS Z");
str = fmt.withLocale(Locale.ENGLISH).print(dt);
System.out.println(str);
System.out.println("################");
DateTime dt2 = fmt.parseDateTime("2000/01/02 03:04:05.006 +0800");
System.out.println(dt2);
}
}