class="java" name="code"> //当前日期 DateTime begin = DateTime.now(); //在begin的基础上增加4天 DateTime end = begin.plusDays(4); //计算区间天数 Period pe = new Period(begin, end, PeriodType.days()); int days = pe.getDays(); System.out.println(days); //格式化yyyymmdd字符串 DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyymmdd"); DateTime dt = DateTime.parse("20140103", formatter); //打印为yyyy-mm-dd System.out.println(dt.toString("yyyy-mm-dd")); //格式化yyyy-mm-dd字符串 DateTime dt0 = DateTime.parse("2014-01-03", DateTimeFormat.forPattern("yyyy-mm-dd")); //打印为yyyymmdd System.out.println(dt0.toString("yyyymmdd")); //转换为jdk的Date java.util.Date dd = dt.toDate();