I am trying create a seed point for Joda-Time. What I am trying to achieve is that I will provide a seed datetime in Joda-Time, this should generate two different random datetime such that datetime1 is before than datetime2 and this datetime will generate values only for that specific hour of seed point.
e.g.
time- 18:00:00 followed by date-2013-02-13
Random1 - 2013-02-13 18:05:24
Random2 - 2013-02-13 18:48:22
The time is received from one DB and the date is selected by the user. I need the two times randomly generated in the specified format
You can see that only the minutes and seconds will change, nothing else will be modified.
Is this possible? How can I achieve this?
The following code should do what you want. If it is possible that the minutes or seconds in your seed time are not zero, you should add .withMinuteOfHour(0).withSecondOfMinute(0) after the
.parseDateTime(inputDateTime)method call.In this solution the first random time is indeed used as the lower bound for the second random time. An alternative solution would be to just get two random dates and then sort them.