SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

JODA-TIME / NOTES</>↗
Joda-Time06 Feb 2012

How do I get number of months between two dates in Joda-Time?

The code below show you how to use the Months class to calculate the different in months between two dates. package org.kodejava.joda; import org.joda.time.DateMidnight; import org.joda.time.LocalDate; import org.joda.time.Months; import java.util.Date; public class MonthsBetweenDemo { public static void main(String[] args) { // Creates an instance of start and end dates. DateMidnight start = new DateMidnight("2021-01-01"); DateMidnight […]

Wayan · 2 min read
JODA-TIME / NOTES</>↗
Joda-Time02 Feb 2012

How do I convert Joda-Time’s DateTime into Calendar or Date object?

This code snippet show you how to convert Joda-Time’s DateTime object into JDK’s java.util.Calendar or java.util.Date object. To convert DateTime to java.util.Date we use the toDate() method and to convert to java.util.Calendar we use the toCalendar() method. package org.kodejava.joda; import org.joda.time.DateTime; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class DateTimeToDateCalendarDemo { public static void main(String[] […]

Wayan · 2 min read
JODA-TIME / NOTES</>↗
Joda-Time02 Feb 2012

How do I do a date calculations in Joda-Time?

Using the Joda-Time library can simplify the date calculation process. For instance, we can add or subtract some days, weeks, months or year easily. There are a plus and minus method for this operation. For instance if you want to add 9 weeks to date object you can do something like date.plusWeeks(9). package org.kodejava.joda; import […]

Wayan · 2 min read
JODA-TIME / NOTES</>↗
Joda-Time02 Feb 2012

How do I format DateTime object in Joda-Time?

The example show you how to format the string representation of a date. In Joda we can use the DateTime‘s class toString() method. The method accept the pattern of the date format and the locale information. package org.kodejava.joda; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import java.util.Locale; public class FormattingDemo { // Define the date format pattern. private […]

Wayan · 2 min read
JODA-TIME / NOTES</>↗
Joda-Time02 Feb 2012

How do I get date and time fields of DateTime object in Joda-Time?

In Joda-Time the date and time information are divided into fields. The following example show you some fields that can be obtained from the DateTime object. For example to get the day of the year we use the getDayOfYear() method and to get the day of week we can use the getDayOfWeek() method. package org.kodejava.joda; […]

Wayan · 2 min read
JODA-TIME / NOTES</>↗
Joda-Time02 Feb 2012

How do I get the first day of the next month in Joda-Time?

This example will give you the first day of the next month from the current system date. In the example we use the MutableDateTime class. MutableDateTime is a datetime class whose value can be modified. In the code snippet we start by creating an instance of MutableDateTime class. We add 1 month from the current […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.