I want to set the hour, minute and seconds in Joda-Time. But when I set it's not changing the property.
Here is my code:
import org.joda.time.DateTime;
public class JodaAkbar
{
public static void main(String args[])
{
DateTime dt = new DateTime();
System.out.println("Before:"+dt);
dt.hourOfDay().setCopy(5);
dt.minuteOfDay().setCopy(20);
dt.secondOfDay().setCopy(0);
System.out.println("After:"+dt);
}
}
Here is the output.
Before:2015-04-01T11:01:38.277+11:00
After:2015-04-01T11:01:38.277+11:00
I am getting the same output. What's happening wrong here?
EDIT:
Basically, I want to do something similar as shown in the below code. As the below code doesn't work properly for 24 hour format, I switched to Joda-Time.
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR, 13);
cal.set(Calendar.MINUTE, 25);
cal.set(Calendar.SECOND, 0);