-
-
Save migueldiab/9295332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Random random = new Random(); | |
private static int MIN = 60 * 1000; | |
private static Calendar cal = Calendar.getInstance(); | |
public static Date randomShiftOnDate(Date someDate) { | |
int randomValue = (random.nextInt(61) - 30) * MIN; // +/- 30 min. | |
long time = someDate.getTime() + randomValue; | |
Date result; | |
synchronized (cal) { | |
result = cal.setTimeInMillis(time).getTime(); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment