Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package joda;
- import org.joda.time.DateTime;
- import org.joda.time.Period;
- import org.joda.time.PeriodType;
- /**
- *
- * @author Kaede
- */
- public class Joda {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- DateTime date1 = new DateTime(2013, 1, 1, 0, 0, 0, 0);
- DateTime date2 = new DateTime(2014, 5, 22, 0, 0, 0, 0);
- System.out.println(calYearMonthDays(date1, date2));
- }
- public static String calYearMonthDays(DateTime date1, DateTime date2)
- {
- Period totDays = new Period(date1, date2, PeriodType.yearMonthDayTime());
- return "Years: "+totDays.getYears()+"\nMonth: "+totDays.getMonths()+"\nDays: "+totDays.getDays();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement