本文整理汇总了Java中java.time.LocalTime.equals方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.equals方法的具体用法?Java LocalTime.equals怎么用?Java LocalTime.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.equals方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: of
import java.time.LocalTime; //导入方法依赖的package包/类
/**
* Obtains an instance defining the yearly rule to create transitions between two offsets.
* <p>
* Applications should normally obtain an instance from {@link ZoneRules}.
* This factory is only intended for use when creating {@link ZoneRules}.
*
* @param month the month of the month-day of the first day of the cutover week, not null
* @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that
* day or later, negative if the week is that day or earlier, counting from the last day of the month,
* from -28 to 31 excluding 0
* @param dayOfWeek the required day-of-week, null if the month-day should not be changed
* @param time the cutover time in the 'before' offset, not null
* @param timeEndOfDay whether the time is midnight at the end of day
* @param timeDefnition how to interpret the cutover
* @param standardOffset the standard offset in force at the cutover, not null
* @param offsetBefore the offset before the cutover, not null
* @param offsetAfter the offset after the cutover, not null
* @return the rule, not null
* @throws IllegalArgumentException if the day of month indicator is invalid
* @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
*/
public static ZoneOffsetTransitionRule of(
Month month,
int dayOfMonthIndicator,
DayOfWeek dayOfWeek,
LocalTime time,
boolean timeEndOfDay,
TimeDefinition timeDefnition,
ZoneOffset standardOffset,
ZoneOffset offsetBefore,
ZoneOffset offsetAfter) {
Objects.requireNonNull(month, "month");
Objects.requireNonNull(time, "time");
Objects.requireNonNull(timeDefnition, "timeDefnition");
Objects.requireNonNull(standardOffset, "standardOffset");
Objects.requireNonNull(offsetBefore, "offsetBefore");
Objects.requireNonNull(offsetAfter, "offsetAfter");
if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
}
if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
}
return new ZoneOffsetTransitionRule(month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefnition, standardOffset, offsetBefore, offsetAfter);
}
示例2: test_plusMinutes_fromZero
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_plusMinutes_fromZero() {
LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
LocalDate d = base.toLocalDate().minusDays(1);
LocalTime t = LocalTime.of(22, 49);
for (int i = -70; i < 70; i++) {
LocalDateTime dt = base.plusMinutes(i);
t = t.plusMinutes(1);
if (t.equals(LocalTime.MIDNIGHT)) {
d = d.plusDays(1);
}
assertEquals(dt.toLocalDate(), d, String.valueOf(i));
assertEquals(dt.toLocalTime(), t, String.valueOf(i));
}
}
示例3: test_minusMinutes_fromZero
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void test_minusMinutes_fromZero() {
LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
LocalDate d = base.toLocalDate().minusDays(1);
LocalTime t = LocalTime.of(22, 49);
for (int i = 70; i > -70; i--) {
LocalDateTime dt = base.minusMinutes(i);
t = t.plusMinutes(1);
if (t.equals(LocalTime.MIDNIGHT)) {
d = d.plusDays(1);
}
assertEquals(dt.toLocalDate(), d);
assertEquals(dt.toLocalTime(), t);
}
}
示例4: validate
import java.time.LocalTime; //导入方法依赖的package包/类
@Override
protected boolean validate() {
LocalDate today = LocalDate.now();
LocalTime start = startTime.getValue();
LocalTime end = endTime.getValue();
if(name.getText().isEmpty()){
MessageHelper.showErrorAlertMessage("The Name is missing.");
name.requestFocus();
return false;
} else if(date.getValue() == null || date.getValue().isBefore(today) ){
MessageHelper.showErrorAlertMessage("The date is not valid.");
date.requestFocus();
return false;
} else if(start == null) {
MessageHelper.showErrorAlertMessage("The starttime is missing.");
return false;
} else if(end != null && (start.isAfter(end) || start.equals(end))) {
MessageHelper.showErrorAlertMessage("The endtime is not after the starttime.");
return false;
} else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
MessageHelper.showErrorAlertMessage("The starttime must be in future.");
return false;
}
return true;
}
示例5: withinTimeSpan
import java.time.LocalTime; //导入方法依赖的package包/类
public static boolean withinTimeSpan(LocalTime startTime, LocalTime endTime, LocalTime timepoint) {
if (startTime.isBefore(endTime)) {
// timespan is wihtin a day
return (timepoint.isAfter(startTime) || timepoint.equals(startTime))
&& (timepoint.isBefore(endTime) || timepoint.equals(endTime));
} else {
// timespan is not within a day (through midnight, e.g. 23:30 - 0:15)
return (timepoint.isAfter(startTime) || timepoint.equals(startTime))
|| (timepoint.isBefore(endTime) || timepoint.equals(endTime));
}
}
示例6: validate
import java.time.LocalTime; //导入方法依赖的package包/类
protected boolean validate() {
LocalDate today = LocalDate.now();
LocalTime start = startTime.getValue();
LocalTime end = endTime.getValue();
if(name.getText().isEmpty()){
MessageHelper.showErrorAlertMessage("The Name is missing.");
name.requestFocus();
return false;
} else if(date.getValue() == null || date.getValue().isBefore(today) ){
MessageHelper.showErrorAlertMessage("The date is not valid.");
date.requestFocus();
return false;
} else if(start == null) {
MessageHelper.showErrorAlertMessage("The starttime is missing.");
return false;
} else if(end != null && (start.isAfter(end) || start.equals(end))) {
MessageHelper.showErrorAlertMessage("The endtime is not after the starttime. ");
return false;
} else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
MessageHelper.showErrorAlertMessage("The starttime must be in future.");
date.requestFocus();
return false;
} else if(musicalWorks == null || musicalWorks.isEmpty()){
MessageHelper.showErrorAlertMessage("A musical work has to be selected.");
return false;
}
return true;
}
示例7: intersect
import java.time.LocalTime; //导入方法依赖的package包/类
public static boolean intersect(LocalTime aStart, LocalTime aEnd,
LocalTime bStart, LocalTime bEnd) {
// Same start time or same end time?
if (aStart.equals(bStart) || aEnd.equals(bEnd)) {
return true;
}
return aStart.isBefore(bEnd) && aEnd.isAfter(bStart);
}
示例8: now_ZoneId
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
LocalTime expected = LocalTime.now(Clock.system(zone));
LocalTime test = LocalTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = LocalTime.now(Clock.system(zone));
test = LocalTime.now(zone);
}
assertEquals(test, expected);
}
示例9: of
import java.time.LocalTime; //导入方法依赖的package包/类
/**
* Obtains an instance defining the yearly rule to create transitions between two offsets.
* <p>
* Applications should normally obtain an instance from {@link ZoneRules}.
* This factory is only intended for use when creating {@link ZoneRules}.
*
* @param month the month of the month-day of the first day of the cutover week, not null
* @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that
* day or later, negative if the week is that day or earlier, counting from the last day of the month,
* from -28 to 31 excluding 0
* @param dayOfWeek the required day-of-week, null if the month-day should not be changed
* @param time the cutover time in the 'before' offset, not null
* @param timeEndOfDay whether the time is midnight at the end of day
* @param timeDefnition how to interpret the cutover
* @param standardOffset the standard offset in force at the cutover, not null
* @param offsetBefore the offset before the cutover, not null
* @param offsetAfter the offset after the cutover, not null
* @return the rule, not null
* @throws IllegalArgumentException if the day of month indicator is invalid
* @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
* @throws IllegalArgumentException if {@code time.getNano()} returns non-zero value
*/
public static ZoneOffsetTransitionRule of(
Month month,
int dayOfMonthIndicator,
DayOfWeek dayOfWeek,
LocalTime time,
boolean timeEndOfDay,
TimeDefinition timeDefnition,
ZoneOffset standardOffset,
ZoneOffset offsetBefore,
ZoneOffset offsetAfter) {
Objects.requireNonNull(month, "month");
Objects.requireNonNull(time, "time");
Objects.requireNonNull(timeDefnition, "timeDefnition");
Objects.requireNonNull(standardOffset, "standardOffset");
Objects.requireNonNull(offsetBefore, "offsetBefore");
Objects.requireNonNull(offsetAfter, "offsetAfter");
if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
}
if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
}
if (time.getNano() != 0) {
throw new IllegalArgumentException("Time's nano-of-second must be zero");
}
return new ZoneOffsetTransitionRule(month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefnition, standardOffset, offsetBefore, offsetAfter);
}
示例10: now_ZoneId
import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
LocalTime expected = LocalTime.now(Clock.system(zone));
LocalTime test = LocalTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = LocalTime.now(Clock.system(zone));
test = LocalTime.now(zone);
}
assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
expected.truncatedTo(ChronoUnit.SECONDS));
}
示例11: withinTimeSpan
import java.time.LocalTime; //导入方法依赖的package包/类
/**
* Method to check whether a give point in time is within a span of time.
*
* @param startTime Start of the time span.
* @param endTime end of the time span.
* @param timePoint checks if this time point is within timespan.
* @return True if the time is within the borders.
*/
public static boolean withinTimeSpan(final LocalTime startTime, final LocalTime endTime, final LocalTime timePoint) {
if (startTime.isBefore(endTime)) {
// timespan is wihtin a day
return (timePoint.isAfter(startTime) || timePoint.equals(startTime))
&& (timePoint.isBefore(endTime) || timePoint.equals(endTime));
} else {
// timespan is not within a day (through midnight, e.g. 23:30 - 0:15)
return (timePoint.isAfter(startTime) || timePoint.equals(startTime))
|| (timePoint.isBefore(endTime) || timePoint.equals(endTime));
}
}
示例12: validate
import java.time.LocalTime; //导入方法依赖的package包/类
@Override
protected boolean validate() {
LocalDate today = LocalDate.now();
LocalTime start = startTime.getValue();
LocalTime end = endTime.getValue();
if(name.getText().isEmpty()){
MessageHelper.showErrorAlertMessage("The Name is missing.");
name.requestFocus();
return false;
} else if(date.getValue() == null || date.getValue().isBefore(today) ){
MessageHelper.showErrorAlertMessage("The date is not valid.");
date.requestFocus();
return false;
} else if(start == null) {
MessageHelper.showErrorAlertMessage("The starttime is missing.");
return false;
} else if(end != null && (start.isAfter(end) || start.equals(end))) {
MessageHelper.showErrorAlertMessage("The endtime is not after the starttime. ");
return false;
} else if(date.getValue().equals(today) && start.isBefore(LocalTime.now())){
MessageHelper.showErrorAlertMessage("The starttime must be in future.");
date.requestFocus();
return false;
}
return true;
}
示例13: updateLineStyling
import java.time.LocalTime; //导入方法依赖的package包/类
private void updateLineStyling() {
T dayView = getSkinnable();
LocalTime startTime = dayView.getStartTime();
LocalTime endTime = dayView.getEndTime();
boolean showEarlyHoursRegion = startTime.isAfter(LocalTime.MIN);
boolean showLateHoursRegion = endTime.isBefore(LocalTime.MAX);
earlyHoursRegion.setVisible(showEarlyHoursRegion);
lateHoursRegion.setVisible(showLateHoursRegion);
int lineCount = lines.size();
for (int i = 0; i < lineCount; i++) {
Line line = lines.get(i);
line.getStyleClass().removeAll("early-hour-line", "late-hour-line"); //$NON-NLS-1$ //$NON-NLS-2$
int hour = (i + 1) / 2;
int minute = 0;
boolean halfHourLine = (i % 2 == 0);
if (halfHourLine) {
minute = 30;
}
LocalTime time = LocalTime.of(hour, minute);
if (time.isBefore(startTime)) {
if (!line.getStyleClass().contains("early-hour-line")) { //$NON-NLS-1$
line.getStyleClass().add("early-hour-line"); //$NON-NLS-1$
}
}
if (time.isAfter(endTime)) {
if (!line.getStyleClass().contains("late-hour-line")) { //$NON-NLS-1$
line.getStyleClass().add("late-hour-line"); //$NON-NLS-1$
}
}
switch (dayView.getEarlyLateHoursStrategy()) {
case HIDE:
/*
* We do not show ... a) lines before the start time and after
* the end time b) lines directly on the start time or end time
* because they make the UI look messy
*/
if (time.isBefore(startTime) || time.equals(startTime) || time.isAfter(endTime) || time.equals(endTime)) {
line.setVisible(false);
} else {
line.setVisible(true);
}
break;
case SHOW:
line.setVisible(true);
break;
case SHOW_COMPRESSED:
if (halfHourLine) {
line.setVisible(false);
} else {
line.setVisible(true);
}
break;
default:
break;
}
}
}