更新时间:2022-06-10 08:32:57
import java.util.Random;
import java.sql.Time;
final Random random = new Random();
final int millisInDay = 24*60*60*1000;
Time time = new Time((long)random.nextInt(millisInDay));
就您的目的而言,这可能就足够了.不要忘记,有些日子的长度不同,您可能需要为其添加测试用例(夏令时和闰秒).
For your purposes this might be enough. Don't forget that some days have different lengths for which you might need to add test cases (daylight savings and leap seconds).