public class DateTimeSource extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static DateTimeSource |
getInstance()
获取唯一实例
|
Date |
randomDate(int year)
随机日期
|
Date |
randomDate(int year,
int month,
int dayOfMonth)
随机时间
|
String |
randomDate(int year,
String pattern)
随机日期
|
Date |
randomDate(java.time.LocalDate beginDate,
java.time.LocalDate endDate)
获取特定范围内的随机日期
|
String |
randomDate(java.time.LocalDate beginDate,
java.time.LocalDate endDate,
String pattern)
获取特定范围内的随机日期
|
Date |
randomFutureDate()
随机未来日期(以当天为基准)
|
Date |
randomFutureDate(int maxDays)
未来的随机时间(以当天为基准)
|
Date |
randomFutureDate(java.time.LocalDate baseDate)
随机未来日期
|
String |
randomFutureDate(java.time.LocalDate baseDate,
String pattern)
随机未来日期
|
Date |
randomFutureDate(java.time.LocalDateTime base,
long maxSeconds)
未来的随机时间
|
String |
randomFutureDate(String pattern)
随机未来日期(以当天为基准)
|
java.time.LocalDate |
randomFutureLocalDate(java.time.LocalDate baseDate)
随机未来日期
|
java.time.LocalDateTime |
randomFutureTime(int maxDays)
未来的随机时间(以当天为基准)
|
java.time.LocalDateTime |
randomFutureTime(java.time.LocalDateTime base,
long maxSeconds)
未来的随机时间
|
long |
randomFutureTimestamp(java.time.LocalDateTime base,
long maxSeconds)
获取未来的随机时间戳(毫秒)
|
java.time.LocalDate |
randomLocalDate(int year)
随机的LocalDate日期
|
java.time.LocalDate |
randomLocalDate(java.time.LocalDate beginDate,
java.time.LocalDate endDate)
获取特定范围内的随机日期
|
Date |
randomPastDate()
随机以往日期(1年内)
|
Date |
randomPastDate(int maxDays)
过去的随机时间(以当天为基准)
|
Date |
randomPastDate(java.time.LocalDate baseDate)
随机以往日期(1年内)
|
Date |
randomPastDate(java.time.LocalDate baseDate,
long maxDays)
随机以往日期
|
String |
randomPastDate(java.time.LocalDate baseDate,
long maxDays,
String pattern)
随机以往日期
|
String |
randomPastDate(java.time.LocalDate baseDate,
String pattern)
随机以往日期(1年内)
|
Date |
randomPastDate(java.time.LocalDateTime base,
long maxSeconds)
过去的随机时间
|
String |
randomPastDate(String pattern)
随机以往日期(1年内)
|
java.time.LocalDate |
randomPastLocalDate(java.time.LocalDate baseDate,
long maxDays)
随机以往日期
|
java.time.LocalDateTime |
randomPastTime(int maxDays)
过去的随机时间(以当天为基准)
|
java.time.LocalDateTime |
randomPastTime(java.time.LocalDateTime base,
long maxSeconds)
过去的随机时间
|
long |
randomPastTimestamp(java.time.LocalDateTime base,
long maxSeconds)
获取过去的随机时间戳(毫秒)
|
java.time.LocalDateTime |
randomTime(int year,
int month,
int dayOfMonth)
随机时间
|
long |
randomTimestamp(java.time.LocalDate date)
获取某一天内的随机时间戳(毫秒)
|
long |
randomTimestamp(java.time.LocalDateTime begin,
java.time.LocalDateTime end)
随机时间戳(毫秒)
|
String |
randomTimezoneName()
获取一个随机的时区名称
|
public static DateTimeSource getInstance()
public String randomDate(int year, String pattern)
year - 年份pattern - 日期格式public Date randomDate(int year)
year - 年份public java.time.LocalDate randomLocalDate(int year)
year - 年份public java.time.LocalDate randomLocalDate(java.time.LocalDate beginDate,
java.time.LocalDate endDate)
beginDate - 范围开始(含)endDate - 范围结束(含)public String randomDate(java.time.LocalDate beginDate, java.time.LocalDate endDate, String pattern)
beginDate - 范围开始(含)endDate - 范围结束(含)pattern - 日期格式public Date randomDate(java.time.LocalDate beginDate, java.time.LocalDate endDate)
beginDate - 范围开始(含)endDate - 范围结束(含)public String randomFutureDate(java.time.LocalDate baseDate, String pattern)
baseDate - 基础日期pattern - 日期格式public java.time.LocalDate randomFutureLocalDate(java.time.LocalDate baseDate)
baseDate - 基础日期public Date randomFutureDate(java.time.LocalDate baseDate)
baseDate - 基础日期public String randomFutureDate(String pattern)
pattern - 日期格式public Date randomFutureDate()
public String randomPastDate(java.time.LocalDate baseDate, long maxDays, String pattern)
baseDate - 基础日期maxDays - 最大日期间隔(天)pattern - 日期格式public java.time.LocalDate randomPastLocalDate(java.time.LocalDate baseDate,
long maxDays)
baseDate - 基础日期maxDays - 最大日期间隔(天)public Date randomPastDate(java.time.LocalDate baseDate, long maxDays)
baseDate - 基础日期maxDays - 最大日期间隔(天)public String randomPastDate(java.time.LocalDate baseDate, String pattern)
baseDate - 基础日期pattern - 日期格式public Date randomPastDate(java.time.LocalDate baseDate)
baseDate - 基础日期public String randomPastDate(String pattern)
pattern - 日期格式public Date randomPastDate()
public java.time.LocalDateTime randomTime(int year,
int month,
int dayOfMonth)
year - 年month - 月dayOfMonth - 日public Date randomDate(int year, int month, int dayOfMonth)
year - 年month - 月dayOfMonth - 日public java.time.LocalDateTime randomPastTime(int maxDays)
maxDays - 最大日期间隔public Date randomPastDate(int maxDays)
maxDays - 最大日期间隔public java.time.LocalDateTime randomPastTime(java.time.LocalDateTime base,
long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒,0或负值表示不限public Date randomPastDate(java.time.LocalDateTime base, long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒,0或负值表示不限public java.time.LocalDateTime randomFutureTime(int maxDays)
maxDays - 最大日期间隔public Date randomFutureDate(int maxDays)
maxDays - 最大日期间隔public java.time.LocalDateTime randomFutureTime(java.time.LocalDateTime base,
long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒,0或负值表示不限public Date randomFutureDate(java.time.LocalDateTime base, long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒,0或负值表示不限public long randomTimestamp(java.time.LocalDateTime begin,
java.time.LocalDateTime end)
begin - 开始时间(含)end - 结束时间(不含)public long randomFutureTimestamp(java.time.LocalDateTime base,
long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒public long randomPastTimestamp(java.time.LocalDateTime base,
long maxSeconds)
base - 基准时间maxSeconds - 最大相差秒public long randomTimestamp(java.time.LocalDate date)
date - 日期public String randomTimezoneName()
Copyright © 2022. All rights reserved.