当前位置: 首页>>代码示例>>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;未经允许,请勿转载。