當前位置: 首頁>>代碼示例>>Java>>正文


Java Date.before方法代碼示例

本文整理匯總了Java中java.util.Date.before方法的典型用法代碼示例。如果您正苦於以下問題:Java Date.before方法的具體用法?Java Date.before怎麽用?Java Date.before使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Date的用法示例。


在下文中一共展示了Date.before方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compararFechaHora

import java.util.Date; //導入方法依賴的package包/類
public static boolean compararFechaHora(EditText f1, EditText h1, String fec1, String fec2){
    Log.d("FECHAS", fec1 + "     " + fec2);
    Date d1 = DateUtilities.stringToDate(fec1);
    Date d2 = DateUtilities.stringToDate(fec2);

    if(d2.before(d1)){
        ((TextInputLayout)f1.getParent().getParent()).setErrorEnabled(true);
        ((TextInputLayout)f1.getParent().getParent()).setError("La fecha de fin no puede ser posterior a la de inicio.");
        ((TextInputLayout)h1.getParent().getParent()).setErrorEnabled(true);
        ((TextInputLayout)h1.getParent().getParent()).setError("");
        return false;
    }
    else{
        return true;
    }
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:17,代碼來源:EditTextValidations.java

示例2: getToSync

import java.util.Date; //導入方法依賴的package包/類
/**
 * Returns a {@link List} of {@link Synchronizer} whose cron expression is
 * triggered between the given parameters.
 * @param start the /start/ Date (exclusive).
 * @param end   the /end/ Date (inclusive).
 * @return a {@link List} of {@link Synchronizer}.
 */
private List<StatSync> getToSync (Date start, Date end) throws InterruptedException
{
   List<StatSync> res = new LinkedList<> ();

   lockSyncMap.lockInterruptibly ();
   try
   {
      for (Map.Entry<CronSchedule, List<StatSync>> e: synchronizers.entrySet ())
      {
         Date next = e.getKey ().cronExpression.getNextValidTimeAfter (start);
         if (next.before (end) || next.equals (end))
         {
            res.addAll (e.getValue ());
         }
      }
   }
   finally
   {
      lockSyncMap.unlock ();
   }
   return res;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:30,代碼來源:ExecutorImpl.java

示例3: getCompletionStatus

import java.util.Date; //導入方法依賴的package包/類
@Override
   public ToolCompletionStatus getCompletionStatus(Long learnerId, Long toolSessionId) {
ChatUser learner = getUserByUserIdAndSessionId(learnerId, toolSessionId);
if (learner == null) {
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_NOT_ATTEMPTED, null, null);
}

Date startDate = null;
Date endDate = learner.getLastPresence();
List<ChatMessage> messages = getMessagesForUser(learner);
for ( ChatMessage message : messages ) {
    Date sendDate = message.getSendDate();
    if ( sendDate != null ) {
	if ( startDate == null || sendDate.before(startDate) )
	    startDate = sendDate;
	if ( endDate == null || sendDate.after(endDate) )
	    endDate = sendDate;
    }
}

if (learner.isFinishedActivity())
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_COMPLETED, startDate, endDate);
else
    return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_ATTEMPTED, startDate, null);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:ChatService.java

示例4: inPast

import java.util.Date; //導入方法依賴的package包/類
/**
 * Checks whether or not a date has already past (IE: March 3, 1990).
 *
 * @param dateRaw  The date to check in format (yyyy/MM/dd-HH:mm:ss).
 * @param timezone The timezone of the calendar this event is for.
 * @return <code>true</code> if the date is in the past, otherwise <code>false</code>.
 */
public static boolean inPast(String dateRaw, TimeZone timezone) {
	try {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss");
		sdf.setTimeZone(timezone);
		Date dateObj = sdf.parse(dateRaw);
		Date now = new Date(System.currentTimeMillis());

		return dateObj.before(now);
	} catch (ParseException e) {
		return true;
	}
}
 
開發者ID:NovaFox161,項目名稱:DisCal-Discord-Bot,代碼行數:20,代碼來源:TimeUtils.java

示例5: nowDateBetweenStartDateAndEndDate

import java.util.Date; //導入方法依賴的package包/類
/**
 * 判斷當前時間是否在在兩個時間之間
 * 
 * @param startDate
 *            開始時間
 * @param endDate
 *            結束時間
 * @return
 */
public static boolean nowDateBetweenStartDateAndEndDate(Date startDate, Date endDate) {

    boolean bool = false;
    Date curDate = new Date();
    if (curDate.after(startDate) && curDate.before(endDate)) {
        bool = true;
    }
    return bool;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:19,代碼來源:DateTimeHelper.java

示例6: checkRefreshRequired

import java.util.Date; //導入方法依賴的package包/類
protected boolean checkRefreshRequired(Date cachedAt) {
	if (cachedAt == null) {
		return true;
	}
	Date now = new Date();
	Date notOlderThen = new Date(now.getTime() - refreshMetadataIfOlderThenSec
			* 1000);

	if (cachedAt.before(notOlderThen)) {
		return true;
	}
	return false;
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:14,代碼來源:CurrentGraphVersionCacheImpl.java

示例7: buildTime

import java.util.Date; //導入方法依賴的package包/類
private static Date buildTime() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 11);//時
    calendar.set(Calendar.MINUTE, 9);//分
    calendar.set(Calendar.SECOND, 0);//秒
    Date time = calendar.getTime();
    if (time.before(new Date())) {
        //若果當前時間已經是淩晨1點後,需要往後加1天,否則任務會立即執行。
        //很多係統往往係統啟動時就需要立即執行一次任務,但下麵又需要每天淩晨1點執行,怎麽辦呢?
        //很簡單,就在係統初始化話時單獨執行一次任務(不需要用定時器,隻是執行那段任務的代碼)
        time = addDay(time, 1);
    }
    return time;
}
 
開發者ID:LuJiangLin,項目名稱:TestDemo1-github,代碼行數:15,代碼來源:TestThread.java

示例8: getEndHour

import java.util.Date; //導入方法依賴的package包/類
/**
 * Recuperar hora com minutos e segundos iguais a 59.
 * @param date informar uma data válida.
 */
public static Date getEndHour(Date date, boolean untilToday) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    Date dateToday = new Date();
    if (untilToday && (dateToday.before(calendar.getTime()))) {
        calendar.setTime(dateToday);
    }
    return calendar.getTime();

}
 
開發者ID:brolam,項目名稱:OpenHomeAnalysis,代碼行數:19,代碼來源:OhaHelper.java

示例9: future

import java.util.Date; //導入方法依賴的package包/類
/**
 * Build a validator that checks that given {@link Date} value is in the future.
 * <p>
 * Supported data types: {@link Date}
 * </p>
 * @param <T> Validator type
 * @param includeTime Whether to include time in validation. If <code>false</code>, only year/month/day are
 *        considered.
 * @param message Validation error message
 * @param messageCode Optional validation error message localization code
 * @return Validator
 */
@SuppressWarnings("serial")
static <T extends Date> Validator<T> future(boolean includeTime, String message, String messageCode) {
	return new BuiltinValidator<T>() {

		@Override
		public void validate(T v) throws ValidationException {
			if (v != null) {
				if (!includeTime) {
					Date today = CalendarUtils.floorTime(Calendar.getInstance()).getTime();
					Date date = CalendarUtils.floorTime(v);
					if (today.equals(date) || date.before(today)) {
						throw new ValidationException(message, messageCode);
					}
				} else {
					if (v.getTime() <= System.currentTimeMillis()) {
						throw new ValidationException(message, messageCode);
					}
				}
			}
		}

		@Override
		public Optional<ValidatorDescriptor> getDescriptor() {
			return Optional.of(ValidatorDescriptor.builder().future().build());
		}
	};
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:40,代碼來源:Validator.java

示例10: isTokenExpired

import java.util.Date; //導入方法依賴的package包/類
private Boolean isTokenExpired(String token) {
    final Date expiration = getExpirationDateFromToken(token);
    return expiration.before(timeProvider.now());
}
 
開發者ID:TomChen001,項目名稱:xmanager,代碼行數:5,代碼來源:JwtTokenUtil.java

示例11: contains

import java.util.Date; //導入方法依賴的package包/類
/**
 * Gibt an, ob das gegebene Datum innerhalb des Zeitraumes ist, d.h. date >= datumVon && date <= datumBis
 */
public boolean contains(Date date) {

	return !date.before(von) && !date.after(bis);
}
 
開發者ID:dvbern,項目名稱:date-helper,代碼行數:8,代碼來源:Zeitraum.java

示例12: isTimeBetween

import java.util.Date; //導入方法依賴的package包/類
private static boolean isTimeBetween(String fromTime, String toTime, String nowTime) throws ParseException {
	String reg = "^([0-1][0-9]|2[0-3]):([0-5][0-9])$";
	if (fromTime.matches(reg) && toTime.matches(reg) && nowTime.matches(reg)) {
		boolean valid;

		Date startTime = new SimpleDateFormat("HH:mm", Locale.US).parse(fromTime);
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.setTime(startTime);

		Date currentTime = new SimpleDateFormat("HH:mm", Locale.US).parse(nowTime);
		Calendar currentCalendar = Calendar.getInstance();
		currentCalendar.setTime(currentTime);

		Date endTime = new SimpleDateFormat("HH:mm", Locale.US).parse(toTime);
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.setTime(endTime);

		if (currentTime.compareTo(endTime) < 0) {
			currentCalendar.add(Calendar.DATE, 1);
			currentTime = currentCalendar.getTime();
		}

		if (startTime.compareTo(endTime) < 0) {
			startCalendar.add(Calendar.DATE, 1);
			startTime = startCalendar.getTime();
		}

		if (currentTime.before(startTime)) {
			valid = false;
		} else {
			if (currentTime.after(endTime)) {
				endCalendar.add(Calendar.DATE, 1);
				endTime = endCalendar.getTime();
			}

			valid = currentTime.before(endTime);
		}
		return valid;
	} else {
		throw new IllegalArgumentException("Not a valid time, expecting HH:mm format");
	}
}
 
開發者ID:SapuSeven,項目名稱:NotiCap,代碼行數:43,代碼來源:NotificationListenerService.java

示例13: isTokenExpired

import java.util.Date; //導入方法依賴的package包/類
private Boolean isTokenExpired(String token) {
    final Date expiration = getExpirationDateFromToken(token);
    return expiration.before(new Date());
}
 
開發者ID:zzqfsy,項目名稱:spring-jwt-starter,代碼行數:5,代碼來源:JwtTokenUtil.java

示例14: getTimeShowString

import java.util.Date; //導入方法依賴的package包/類
public static String getTimeShowString(long milliseconds, boolean abbreviate) {
    String dataString;
    String timeStringBy24;

    Date currentTime = new Date(milliseconds);
    Date today = new Date();
    Calendar todayStart = Calendar.getInstance();
    todayStart.set(Calendar.HOUR_OF_DAY, 0);
    todayStart.set(Calendar.MINUTE, 0);
    todayStart.set(Calendar.SECOND, 0);
    todayStart.set(Calendar.MILLISECOND, 0);
    Date todaybegin = todayStart.getTime();
    Date yesterdaybegin = new Date(todaybegin.getTime() - 3600 * 24 * 1000);
    Date preyesterday = new Date(yesterdaybegin.getTime() - 3600 * 24 * 1000);

    if (!currentTime.before(todaybegin)) {
        dataString = "今天";
    } else if (!currentTime.before(yesterdaybegin)) {
        dataString = "昨天";
    } else if (!currentTime.before(preyesterday)) {
        dataString = "前天";
    } else if (isSameWeekDates(currentTime, today)) {
        dataString = getWeekOfDate(currentTime);
    } else {
        SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
        dataString = dateformatter.format(currentTime);
    }

    SimpleDateFormat timeformatter24 = new SimpleDateFormat("HH:mm", Locale.getDefault());
    timeStringBy24 = timeformatter24.format(currentTime);

    if (abbreviate) {
        if (!currentTime.before(todaybegin)) {
            return getTodayTimeBucket(currentTime);
        } else {
            return dataString;
        }
    } else {
        return dataString + " " + timeStringBy24;
    }
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:42,代碼來源:TimeUtil.java

示例15: isCreatedBeforeLastPasswordReset

import java.util.Date; //導入方法依賴的package包/類
private Boolean isCreatedBeforeLastPasswordReset(Date created, Date lastPasswordReset) {
    return (lastPasswordReset != null && created.before(lastPasswordReset));
}
 
開發者ID:quebic-source,項目名稱:microservices-sample-project,代碼行數:4,代碼來源:JwtTokenUtil.java


注:本文中的java.util.Date.before方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。