本文整理匯總了Java中org.apache.commons.lang.time.DateUtils.isSameDay方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.isSameDay方法的具體用法?Java DateUtils.isSameDay怎麽用?Java DateUtils.isSameDay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.time.DateUtils
的用法示例。
在下文中一共展示了DateUtils.isSameDay方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filterByCreateDate
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 使用創建日期來過濾發布單
*
* @param releaseForms
* @param createDate
* @return
*/
private List<ReleaseForm> filterByCreateDate(List<ReleaseForm> releaseForms, Date createDate) {
// 未限定
if (createDate == null) {
return releaseForms;
}
List<ReleaseForm> filteredReleaseFormList = new ArrayList<>();
for (ReleaseForm form : releaseForms) {
if (DateUtils.isSameDay(form.getCreateTime(), createDate)) {
filteredReleaseFormList.add(form);
}
}
return filteredReleaseFormList;
}
示例2: filterByReleaseDate
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 使用發布日期來過濾發布單
*
* @param releaseForms
* @param releaseDate
* @return
*/
private List<ReleaseForm> filterByReleaseDate(List<ReleaseForm> releaseForms, Date releaseDate) {
// 未限定
if (releaseDate == null) {
return releaseForms;
}
List<ReleaseForm> filteredReleaseFormList = new ArrayList<>();
for (ReleaseForm form : releaseForms) {
if (DateUtils.isSameDay(form.getCreateTime(), releaseDate)) {
filteredReleaseFormList.add(form);
}
}
return filteredReleaseFormList;
}
示例3: getFromAppCommandStats
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public static HighchartPoint getFromAppCommandStats(AppCommandStats appCommandStats, Date currentDate, int diffDays) throws ParseException {
Date collectDate = getDateTime(appCommandStats.getCollectTime());
if (!DateUtils.isSameDay(currentDate, collectDate)) {
return null;
}
//顯示用的時間
String date = null;
try {
date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH:mm");
} catch (Exception e) {
date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH");
}
// y坐標
long commandCount = appCommandStats.getCommandCount();
// x坐標
//為了顯示在一個時間範圍內
if (diffDays > 0) {
collectDate = DateUtils.addDays(collectDate, diffDays);
}
return new HighchartPoint(collectDate.getTime(), commandCount, date);
}
示例4: hasSectionToday
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* Section generated today?
*
* @return {@code true} if section generated, returns {@code false} otherwise
*/
public synchronized boolean hasSectionToday() {
try {
final Query query = new Query().addSort(Keys.OBJECT_ID, SortDirection.DESCENDING).
setCurrentPageNum(1).setPageSize(1);
query.setFilter(new PropertyFilter(Article.ARTICLE_TYPE, FilterOperator.EQUAL,
Article.ARTICLE_TYPE_C_JOURNAL_SECTION));
final JSONObject result = articleRepository.get(query);
final List<JSONObject> journals = CollectionUtils.<JSONObject>jsonArrayToList(result.optJSONArray(Keys.RESULTS));
if (journals.isEmpty()) {
return false;
}
final JSONObject maybeToday = journals.get(0);
final long created = maybeToday.optLong(Article.ARTICLE_CREATE_TIME);
return DateUtils.isSameDay(new Date(created), new Date());
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Check section generated failed", e);
return false;
}
}
示例5: resolvePaymentDTO
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* Reads the payment DTO from the form
*/
@Override
protected DoPaymentDTO resolvePaymentDTO(final ActionContext context) {
final DoPaymentDTO dto = super.resolvePaymentDTO(context);
dto.setContext(TransactionContext.PAYMENT);
final PaymentForm form = context.getForm();
if (form.isToSystem()) {
dto.setTo(SystemAccountOwner.instance());
}
// When there is a single payment scheduled for today, remove it, making the payment to be processed now
final List<ScheduledPaymentDTO> payments = dto.getPayments();
if (payments != null && payments.size() == 1) {
final ScheduledPaymentDTO payment = payments.get(0);
if (DateUtils.isSameDay(Calendar.getInstance(), payment.getDate())) {
// A single payment scheduled for today is handled as not scheduled
dto.setPayments(null);
}
}
return dto;
}
示例6: displayAsSelectedExpiry
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public boolean displayAsSelectedExpiry(int months) {
if (previousConsentToView == null) return (months == -1);
else {
if (previousConsentToView.getExpiry() == null) return (months == -1);
else {
GregorianCalendar cal1 = new GregorianCalendar();
cal1.setTime(previousConsentToView.getCreatedDate());
cal1.add(Calendar.MONTH, months);
return (DateUtils.isSameDay(cal1.getTime(), previousConsentToView.getExpiry()));
}
}
}
示例7: deleteBedDemographic
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public void deleteBedDemographic(BedDemographic bedDemographic) {
// save historical
if (!DateUtils.isSameDay(bedDemographic.getReservationStart(), Calendar.getInstance().getTime())) {
BedDemographicHistorical historical = BedDemographicHistorical.create(bedDemographic);
persist(historical);
}
// delete
remove(bedDemographic.getId());
}
示例8: getColumnCaption
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public static String getColumnCaption(String columnId, Date date) {
String caption = messages.getMessage(WeeklyReportEntry.class, "WeeklyReportEntry." + columnId);
String format = COMMON_DAY_CAPTION_STYLE;
if (workdaysTools.isHoliday(date) || workdaysTools.isWeekend(date)) {
format = String.format(HOLIDAY_CAPTION_STYLE, format);
}
if (DateUtils.isSameDay(timeSource.currentTimestamp(), date)) {
format = String.format(TODAY_CAPTION_STYLE, format);
}
return String.format(format, caption, DateUtils.toCalendar(date).get(Calendar.DAY_OF_MONTH));
}
示例9: getFromAppStats
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public static HighchartPoint getFromAppStats(AppStats appStat, String statName, Date currentDate, int diffDays) throws ParseException {
Date collectDate = getDateTime(appStat.getCollectTime());
if (!DateUtils.isSameDay(currentDate, collectDate)) {
return null;
}
//顯示用的時間
String date = null;
try {
date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH:mm");
} catch (Exception e) {
date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH");
}
// y坐標
long count = 0;
if ("hits".equals(statName)) {
count = appStat.getHits();
} else if ("misses".equals(statName)) {
count = appStat.getMisses();
} else if ("usedMemory".equals(statName)) {
count = appStat.getUsedMemory() / 1024 / 1024;
} else if ("netInput".equals(statName)) {
count = appStat.getNetInputByte();
} else if ("netOutput".equals(statName)) {
count = appStat.getNetOutputByte();
} else if ("connectedClient".equals(statName)) {
count = appStat.getConnectedClients();
} else if ("objectSize".equals(statName)) {
count = appStat.getObjectSize();
} else if ("hitPercent".equals(statName)) {
count = appStat.getHitPercent();
}
//為了顯示在一個時間範圍內
if (diffDays > 0) {
collectDate = DateUtils.addDays(collectDate, diffDays);
}
return new HighchartPoint(collectDate.getTime(), count, date);
}
示例10: isCheckedinToday
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* Does checkin today?
*
* @param userId the specified user id
* @return {@code true} if checkin succeeded, returns {@code false} otherwise
*/
public synchronized boolean isCheckedinToday(final String userId) {
final Calendar calendar = Calendar.getInstance();
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour < Symphonys.getInt("activityDailyCheckinTimeMin")
|| hour > Symphonys.getInt("activityDailyCheckinTimeMax")) {
return true;
}
final Date now = new Date();
JSONObject user = userCache.getUser(userId);
try {
if (null == user) {
user = userRepository.get(userId);
}
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Checks checkin failed", e);
return true;
}
final List<JSONObject> records = pointtransferQueryService.getLatestPointtransfers(userId,
Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_CHECKIN, 1);
if (records.isEmpty()) {
return false;
}
final JSONObject maybeToday = records.get(0);
final long time = maybeToday.optLong(Pointtransfer.TIME);
return DateUtils.isSameDay(now, new Date(time));
}
示例11: is1A0001Today
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* Does participate 1A0001 today?
*
* @param userId the specified user id
* @return {@code true} if participated, returns {@code false} otherwise
*/
public synchronized boolean is1A0001Today(final String userId) {
final Date now = new Date();
final List<JSONObject> records = pointtransferQueryService.getLatestPointtransfers(userId,
Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_1A0001, 1);
if (records.isEmpty()) {
return false;
}
final JSONObject maybeToday = records.get(0);
final long time = maybeToday.optLong(Pointtransfer.TIME);
return DateUtils.isSameDay(now, new Date(time));
}
示例12: isCollected1A0001Today
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* Did collect 1A0001 today?
*
* @param userId the specified user id
* @return {@code true} if collected, returns {@code false} otherwise
*/
public synchronized boolean isCollected1A0001Today(final String userId) {
final Date now = new Date();
final List<JSONObject> records = pointtransferQueryService.getLatestPointtransfers(userId,
Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_1A0001_COLLECT, 1);
if (records.isEmpty()) {
return false;
}
final JSONObject maybeToday = records.get(0);
final long time = maybeToday.optLong(Pointtransfer.TIME);
return DateUtils.isSameDay(now, new Date(time));
}
示例13: checkAndSendAdmissionIntervalNotification
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* This method will check the given program for admissions/referrals
* in the last "day". It will then send an email if any admission/referrals
* have been made in that timeframe.
*
* The expectation is that a background thread will call this method, not
* end-user-actions.
*/
public void checkAndSendAdmissionIntervalNotification(Program program) throws IOException {
if (!enableEmailNotifications) return;
InputStream is = null;
String emailTemplate = null;
try {
is = WaitListManager.class.getResourceAsStream(WAIT_LIST_DAILY_ADMISSION_EMAIL_TEMPLATE_FILE);
emailTemplate = IOUtils.toString(is);
} finally {
if (is != null) is.close();
}
String emailSubject = waitListProperties.getProperty("daily_admission_subject");
// check if we need to run, might already have been run
Date lastNotificationDate = program.getLastReferralNotification();
// if first run, set default to a few days ago and let it sort itself out.
if (lastNotificationDate == null) lastNotificationDate = new Date(System.currentTimeMillis() - (DateUtils.MILLIS_PER_DAY * 4));
Date today = new Date();
if (DateUtils.isSameDay(lastNotificationDate, today) || lastNotificationDate.after(today)) return;
// get a list of the admissions between since last notification date.
// send a notification for those admissions
// update last notification date
Date endDate = new Date(lastNotificationDate.getTime() + waitListNotificationPeriod);
List<Admission> admissions = admissionDao.getAdmissionsByProgramAndAdmittedDate(program.getId(), lastNotificationDate, endDate);
logger.debug("For programId=" + program.getId() + ", " + lastNotificationDate + " to " + endDate + ", admission count=" + admissions.size());
ArrayList<AdmissionDemographicPair> admissionDemographicPairs = new ArrayList<AdmissionDemographicPair>();
for (Admission admission : admissions) {
AdmissionDemographicPair admissionDemographicPair = new AdmissionDemographicPair();
admissionDemographicPair.setAdmission(admission);
admissionDemographicPair.setDemographic(demographicDao.getDemographicById(admission.getClientId()));
admissionDemographicPairs.add(admissionDemographicPair);
}
sendAdmissionNotification(emailSubject, emailTemplate, program, null, lastNotificationDate, endDate, admissionDemographicPairs);
program.setLastReferralNotification(endDate);
programDao.saveProgram(program);
}
示例14: isSameDay
import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
* 判斷兩個日期是否相等 具體到 day
*
* @return 相等時返回 true
*/
public static boolean isSameDay(Date date1, Date date2) {
return DateUtils.isSameDay(date1, date2);
}