本文整理汇总了Java中org.apache.commons.lang3.time.DateUtils.addHours方法的典型用法代码示例。如果您正苦于以下问题:Java DateUtils.addHours方法的具体用法?Java DateUtils.addHours怎么用?Java DateUtils.addHours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.time.DateUtils
的用法示例。
在下文中一共展示了DateUtils.addHours方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPasswordRecoveryToken
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
public SmartiUser createPasswordRecoveryToken(String login) {
final SmartiUser mongoUser = findUser(login);
if (mongoUser == null) {
return null;
}
final Date now = new Date(),
expiry = DateUtils.addHours(now, 24);
final String token = HashUtils.sha256(UUID.randomUUID() + mongoUser.getLogin());
final SmartiUser.PasswordRecovery recovery = new SmartiUser.PasswordRecovery(token, now, expiry);
final WriteResult result = updateMongoUser(mongoUser.getLogin(), Update.update(SmartiUser.FIELD_RECOVERY, recovery));
if (result.getN() == 1) {
return getSmaritUser(mongoUser.getLogin());
} else {
return null;
}
}
示例2: addHours
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
/**
* 加一小时
*/
public static Date addHours(@NotNull final Date date, int amount) {
return DateUtils.addHours(date, amount);
}
示例3: updateDiscList
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
private void updateDiscList(Element table, String updateText) {
DiscList discList = getDiscList(table.parent().id());
if (!updateText.equals("更新中")) {
Date japanDate = parseDate(update, updateText);
Date chinaDate = DateUtils.addHours(japanDate, -1);
updateDiscList(table, discList, chinaDate);
}
}
示例4: subHours
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
/**
* 减一小时
*/
public static Date subHours(@NotNull final Date date, int amount) {
return DateUtils.addHours(date, -amount);
}
示例5: loadFile
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
protected Collection<File> loadFile(FhirContext theCtx, String theSpecUrl, String theFilepath, boolean theCacheFile) throws IOException {
String userHomeDir = System.getProperty("user.home");
File applicationDir = new File(userHomeDir + File.separator + "." + "hapi-fhir-cli");
FileUtils.forceMkdir(applicationDir);
Collection<File> inputFiles;
if (isNotBlank(theFilepath)) {
ourLog.info("Loading from local path: {}", theFilepath);
if (theFilepath.startsWith("~" + File.separator)) {
theFilepath = userHomeDir + theFilepath.substring(1);
}
File suppliedFile = new File(FilenameUtils.normalize(theFilepath));
if (suppliedFile.isDirectory()) {
inputFiles = FileUtils.listFiles(suppliedFile, new String[]{"zip"}, false);
} else {
inputFiles = Collections.singletonList(suppliedFile);
}
} else {
File cacheDir = new File(applicationDir, "cache");
FileUtils.forceMkdir(cacheDir);
File inputFile = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip");
Date cacheExpiryDate = DateUtils.addHours(new Date(), -12);
if (!inputFile.exists() | (theCacheFile && FileUtils.isFileOlder(inputFile, cacheExpiryDate))) {
File exampleFileDownloading = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip.partial");
HttpGet get = new HttpGet(theSpecUrl);
CloseableHttpClient client = HttpClientBuilder.create().build();
CloseableHttpResponse result = client.execute(get);
if (result.getStatusLine().getStatusCode() != 200) {
throw new CommandFailureException("Got HTTP " + result.getStatusLine().getStatusCode() + " response code loading " + theSpecUrl);
}
ourLog.info("Downloading from remote url: {}", theSpecUrl);
downloadFileFromInternet(result, exampleFileDownloading);
FileUtils.deleteQuietly(inputFile);
FileUtils.moveFile(exampleFileDownloading, inputFile);
if (!theCacheFile) {
inputFile.deleteOnExit();
}
ourLog.info("Successfully Loaded example pack ({})", FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(inputFile)));
IOUtils.closeQuietly(result.getEntity().getContent());
}
inputFiles = Collections.singletonList(inputFile);
}
return inputFiles;
}
示例6: addHours
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
/**
* @param date 当前时间
* @param amount 增加小时数
* @return 增加后时间
* @description 增加小时
*/
public static Date addHours(Date date, int amount) {
return DateUtils.addHours(date, amount);
}
示例7: addMinutes
import org.apache.commons.lang3.time.DateUtils; //导入方法依赖的package包/类
/**
* @param date 当前时间
* @param amount 增加分钟数
* @return 增加后时间
* @description 增加分钟
*/
public static Date addMinutes(Date date, int amount) {
return DateUtils.addHours(date, amount);
}