本文整理匯總了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;
}