本文整理汇总了Java中java.time.LocalDateTime.equals方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.equals方法的具体用法?Java LocalDateTime.equals怎么用?Java LocalDateTime.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMonthNumbersInDateFrame
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static List<Integer> getMonthNumbersInDateFrame(Date startDate, Date endDate) {
List<Integer> dates = new ArrayList<>();
LocalDateTime start = asLocalDateTime(startDate);
LocalDateTime end = asLocalDateTime(endDate);
while (start.isBefore(end) || start.equals(end)) {
dates.add(start.getMonthValue());
start = start.plusMonths(1);
}
return dates;
}
示例2: handleMouseUp
import java.time.LocalDateTime; //导入方法依赖的package包/类
private void handleMouseUp(double eventX, double eventY) {
if (null != selectedSpot) {
long fromMins = Math.round((dragStartX - TwoDayViewPresenter.SPOT_NAME_WIDTH - presenter.getState()
.getOffsetX())
/ (presenter.getState().getWidthPerMinute()
* presenter.getConfig().getEditMinuteGradality())) * presenter.getConfig()
.getEditMinuteGradality();
LocalDateTime from = LocalDateTime.ofEpochSecond(60 * fromMins, 0, ZoneOffset.UTC).plusSeconds(
presenter.getState().getViewStartDate().toEpochSecond(ZoneOffset.UTC) - presenter.getState()
.getBaseDate().toEpochSecond(
ZoneOffset.UTC));
long toMins = Math.max(0, Math.round((mouseX - TwoDayViewPresenter.SPOT_NAME_WIDTH - presenter.getState()
.getOffsetX())
/ (presenter.getState().getWidthPerMinute()
* presenter.getConfig().getEditMinuteGradality()))) * presenter.getConfig()
.getEditMinuteGradality();
LocalDateTime to = LocalDateTime.ofEpochSecond(60 * toMins, 0, ZoneOffset.UTC).plusSeconds(
presenter.getState().getViewStartDate().toEpochSecond(ZoneOffset.UTC) - presenter.getState()
.getBaseDate().toEpochSecond(
ZoneOffset.UTC));
if (to.equals(from)) {
return;
} else if (to.isBefore(from)) {
LocalDateTime tmp = to;
to = from;
from = tmp;
}
presenter.getCalendar().addShift(selectedSpot, from, to);
}
}
示例3: equals
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public boolean equals(Object x, Object y) throws HibernateException {
if (x == y) {
return true;
}
if ((x == null) || (y == null)) {
return false;
}
LocalDateTime dtx = (LocalDateTime) x;
LocalDateTime dty = (LocalDateTime) y;
return dtx.equals(dty);
}
示例4: now_ZoneId
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
LocalDateTime expected = LocalDateTime.now(Clock.system(zone));
LocalDateTime test = LocalDateTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = LocalDateTime.now(Clock.system(zone));
test = LocalDateTime.now(zone);
}
assertEquals(test, expected);
}
示例5: now_ZoneId
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
LocalDateTime expected = LocalDateTime.now(Clock.system(zone));
LocalDateTime test = LocalDateTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = LocalDateTime.now(Clock.system(zone));
test = LocalDateTime.now(zone);
}
assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
expected.truncatedTo(ChronoUnit.SECONDS));
}
示例6: assertTimeInRaidTimespan
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void assertTimeInRaidTimespan(User user, LocalDateTime dateTimeToCheck, Raid raid,
LocaleService localeService) {
final LocalDateTime startOfRaid = getStartOfRaid(raid.getEndOfRaid(), raid.isExRaid());
final boolean timeIsSameOrBeforeEnd =
raid.getEndOfRaid().isAfter(dateTimeToCheck) || raid.getEndOfRaid().equals(dateTimeToCheck);
final boolean timeIsSameOrAfterStart =
startOfRaid.isBefore(dateTimeToCheck) || startOfRaid.equals(dateTimeToCheck);
if (!(timeIsSameOrBeforeEnd && timeIsSameOrAfterStart)) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.TIME_NOT_IN_RAID_TIMESPAN,
localeService.getLocaleForUser(user), printDateTime(dateTimeToCheck),
printDateTime(startOfRaid), printTimeIfSameDay(raid.getEndOfRaid())));
}
}
示例7: changeGroupTime
import java.time.LocalDateTime; //导入方法依赖的package包/类
private boolean changeGroupTime(CommandEvent commandEvent, Config config, User user, String userName, Raid raid,
LocalDateTime newDateTime) {
boolean groupChanged = false;
final Set<RaidGroup> groups = raidRepository.getGroups(raid);
final Set<EmoticonSignUpMessageListener> listenersToCheck =
getListenersToCheck(commandEvent, config, user, raid, groups);
for (EmoticonSignUpMessageListener listener : listenersToCheck) {
final String raidId = raid.getId();
final LocalDateTime currentStartAt = listener.getStartAt();
if (currentStartAt != null && currentStartAt.equals(newDateTime)) {
LOGGER.info("Group is already at input time.");
// This group is already at the time to change to
commandEvent.reactError();
} else if (currentStartAt != null) {
LOGGER.info("Changing group time from " + currentStartAt + " to " + newDateTime);
RaidGroup raidGroup = raidRepository.changeGroup(user, raidId, listener.getUserId(),
currentStartAt, newDateTime);
raidRepository.moveAllSignUpsForTimeToNewTime(raidId, currentStartAt, newDateTime, user);
listener.setStartAt(newDateTime);
groupChanged = true;
replyBasedOnConfigAndRemoveAfter(config, commandEvent,
localeService.getMessageFor(LocaleService.MOVED_GROUP,
localeService.getLocaleForUser(user),
printTimeIfSameDay(currentStartAt),
printTimeIfSameDay(newDateTime), raid.getGym().getName()),
BotServerMain.timeToRemoveFeedbackInSeconds);
LOGGER.info("Group time changed. Group: " + raidGroup);
commandEvent.reactSuccess();
} else {
LOGGER.info("Group is about to get cleaned up.");
commandEvent.reactError();
// This group is about to get cleaned up since its start time is null
replyBasedOnConfigAndRemoveAfter(config, commandEvent,
localeService.getMessageFor(LocaleService.GROUP_CLEANING_UP,
localeService.getLocaleForUser(user)),
BotServerMain.timeToRemoveFeedbackInSeconds);
return true;
}
}
if (!groupChanged) {
throw new UserMessedUpException(userName,
localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user),
"!raid change group 10:00 solna platform"));
}
return false;
}