logo

Using Joda time

Joda time is a popular open source library that provides replacement for the standard Java date and time classes like Date, Calendar and SimpleDateFormat.

Joda time is a popular open source library that provides replacement for the standard Java date and time classes like Date, Calendar and SimpleDateFormat. Lot's of projects use Joda time instead JDK date and time.

Joda time is interoperable with JDK date and time.

First add Joda time JARs to build path.

To get current date create instance of DateTime class:

DateTime currentDate = new DateTime();

 

To get current day, month, year etc. call getDayOfMonth(), getMonthOfYear(), getYear() etc.

To add or subtract call plusXXX() or minusXXX() method.

To format or parse date use class DateTimeFormatter.

All of this is much easier than using standard JDK date and time.


comments powered by Disqus

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search