I'm working on a method that can tell me if a certain date is within a certain period of dates. My method will have an argument of two DateTime objects; a start date and end date, and will be called by a DateTime object as well.
To play around with it, I've been trying to figure out how to extract the year, month, day , time, from a DateTime object that is being compared to. However I can't figure out how to get it going. I checked the API for DateTime, and the method it has to perform the function I want is monthOfYear().
But when I implement it, it outputs "Property[monthOfYear]".
The API places the method under DateTime.Property but I played around with that too and I'm not getting anywhere.
import org.joda.time.DateTime; public class Tester implements TesterInterface { public static void main(String[] args) { DateTime dateTime1 = new DateTime(2012, 5, 12, 13, 30); System.out.println(dateTime1.monthOfYear()); }
}
Call getMonthOfYear()
.
As documented:
Each individual field can be queried in two ways:
- getHourOfDay()
- hourOfDay().get()