- Joda Time provides better api methods then java util date.
- joda time api can be downloaded:-
Project Structure:-
Test Joda Time:-
package com.sandeep.joda.time;
import java.util.Calendar;
import java.util.Date;
import org.joda.time.DateTime;
public class JodaTimeTest {
public static void main(String[] args) {
//Joda Time Date
DateTime jodadate = new DateTime();
System.out.print("Joda time today : "+jodadate+"n");
DateTime jodatomorrow = jodadate.plusDays(1);
System.out.print("Joda time tomorrow : "+jodatomorrow+"n");
//Java util time Date
Date utilday = new Date();
System.out.print("Java Util today : "+utilday+"n");
Calendar cal = Calendar.getInstance();
cal.setTime(utilday);
cal.add(Calendar.DATE, 1);
Date utiltomorrow=cal.getTime();
System.out.print("Java Util tomorrow :"+utiltomorrow+"n");
}
}
Output:-
Joda time today : 2012-12-10T21:48:53.468+05:30
Joda time tomorrow : 2012-12-11T21:48:53.468+05:30
Java Util today : Mon Dec 10 21:48:53 IST 2012
Java Util tomorrow :Tue Dec 11 21:48:53 IST 2012