本文整理汇总了Java中org.joda.time.DateMidnight类的典型用法代码示例。如果您正苦于以下问题:Java DateMidnight类的具体用法?Java DateMidnight怎么用?Java DateMidnight使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateMidnight类属于org.joda.time包,在下文中一共展示了DateMidnight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEventRecordForJob
import org.joda.time.DateMidnight; //导入依赖的package包/类
private TimedEventRecord getEventRecordForJob(CallingContext context, String jobUri) {
RaptureJob job = retrieveJob(context, jobUri);
CronParser parser = MultiCronParser.create(job.getCronSpec());
DateTime midnight = DateMidnight.now().toDateTime(DateTimeZone.forID(job.getTimeZone()));
DateTime nextRunDate = parser.nextRunDate(midnight);
if (nextRunDate != null) {
TimedEventRecord record = new TimedEventRecord();
record.setEventName(job.getDescription());
record.setEventContext(jobUri);
record.setInfoContext(job.getActivated().toString());
record.setWhen(nextRunDate.toDate());
return record;
} else {
return null;
}
}
示例2: getCommitAuthors
import org.joda.time.DateMidnight; //导入依赖的package包/类
public GerritAuthorsAndReviewersList getCommitAuthors(final String changeStatus, String projectFilterString,
final String projectFilterOutString,
DateTime startDate, DateTime endDate) throws IOException, URISyntaxException {
if(null == changeStatus || changeStatus.isEmpty()) {
throw new RuntimeException("Error change status cannot be null");
}
if(null == projectFilterString) {
projectFilterString = ALL_REGEX;
}
if(null == startDate) {
startDate = new DateTime(0);
}
if(null == endDate) {
// Search far enough into future to offset any chance of incorrect
// time syncs between servers.
endDate = new DateMidnight().plusYears(CURRENT_TIME_OFFSET).toDateTime();
}
return statisticsService.getCommitAuthors(changeStatus, projectFilterString, projectFilterOutString, startDate,
endDate);
}
示例3: getReviewStatistics
import org.joda.time.DateMidnight; //导入依赖的package包/类
public GerritReviewStats getReviewStatistics(final String changeStatus, String projectFilterString,
String projectFilterOutString,
DateTime startDate, DateTime endDate) throws IOException, URISyntaxException {
if(null == changeStatus || changeStatus.isEmpty()) {
throw new RuntimeException("Error change status cannot be null");
}
if(null == projectFilterString) {
projectFilterString = ALL_REGEX;
}
if(null == projectFilterOutString) {
projectFilterOutString = "";
}
if(null == startDate) {
startDate = new DateTime(0);
}
if(null == endDate) {
// Search far enough into future to offset any chance of incorrect
// time syncs between servers.
endDate = new DateMidnight().plusYears(CURRENT_TIME_OFFSET).toDateTime();
}
return statisticsService.getReviewStatistics(changeStatus, projectFilterString, projectFilterOutString,
startDate, endDate);
}
示例4: shouldResetOnlineSecondsToday
import org.joda.time.DateMidnight; //导入依赖的package包/类
/**
* static method for calculating the current value of the "onlineSecondsToday" field. Usually returns the same value, unless
* @param user
* @return
*/
public static boolean shouldResetOnlineSecondsToday(User user) {
DateTimeZone timeZone = null;
try {
timeZone = DateTimeZone.forID(user.getProfile().getTimeZoneId());
} catch (IllegalArgumentException ex) {
logger.warn("No time zone found for ID=" + user.getProfile().getTimeZoneId());
// zone not found
timeZone = DateTimeZone.UTC;
}
// if the last login is yesterday, set the secondsToday to zero
if (new DateTime(user.getLastLogin(), DateTimeZone.forID("GMT")).isBefore(new DateMidnight(timeZone))) {
return true;
}
return false;
}
示例5: testBigHashtable
import org.joda.time.DateMidnight; //导入依赖的package包/类
public void testBigHashtable() {
Converter[] array = new Converter[] {
c1, c2, c3, c4,
};
ConverterSet set = new ConverterSet(array);
set.select(Boolean.class);
set.select(Character.class);
set.select(Byte.class);
set.select(Short.class);
set.select(Integer.class);
set.select(Long.class);
set.select(Float.class);
set.select(Double.class);
set.select(null);
set.select(Calendar.class);
set.select(GregorianCalendar.class);
set.select(DateTime.class);
set.select(DateMidnight.class);
set.select(ReadableInstant.class);
set.select(ReadableDateTime.class);
set.select(ReadWritableInstant.class); // 16
set.select(ReadWritableDateTime.class);
set.select(DateTime.class);
assertEquals(4, set.size());
}
示例6: getMenorMes
import org.joda.time.DateMidnight; //导入依赖的package包/类
/**
* @param companyId
* @return
* @throws SystemException
*/
private DateMidnight getMenorMes(long companyId) throws SystemException {
Date menorDataMessage = buscaData(
"select min(createDate) from MBMessage where companyId = ?",
companyId);
Date menorDataChat = buscaData(
"select min(a.messageTS) from CDChat_ChatRoomMessage a "
+ "JOIN CDChat_ChatRoom b ON a.chatRoomId = b.roomId "
+ "JOIN Group_ c on b.groupId = c.groupId "
+ "WHERE a.messageType = 0 and a.messageStatus = 1 and c.companyId = ?",
companyId);
if (menorDataMessage == null) // Se não tiver nenhuma mensagem
menorDataMessage = new Date();
if (menorDataChat == null)
menorDataChat = new Date();
Date menorData = menorDataMessage.before(menorDataChat) ? menorDataMessage
: menorDataChat;
DateMidnight mes = new DateMidnight(menorData.getTime(),
DateTimeZone.forTimeZone(TimeZoneUtil.getDefault()));
mes = mes.withDayOfMonth(1);
return mes;
}
示例7: testIsSnapshotRequired
import org.joda.time.DateMidnight; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testIsSnapshotRequired() throws Exception {
StreamService service = new StreamService();
Period period = Period.days(2);
Collection<Snapshot> snapshots = new ArrayList<>();
snapshots.add(new Snapshot(0, new DateTime(2014, 1, 1, 0, 0), null));
snapshots.add(new Snapshot(0, new DateTime(2014, 1, 2, 0, 0), null));
snapshots.add(new Snapshot(0, new DateTime(2014, 1, 3, 0, 0), null));
assertThat(service.isSnapshotRequired(
new DateMidnight(2014, 1, 3).toInstant(), period, snapshots),
is(false));
assertThat(service.isSnapshotRequired(
new DateMidnight(2014, 1, 4).toInstant(), period, snapshots),
is(false));
assertThat(service.isSnapshotRequired(
new DateMidnight(2014, 1, 5).toInstant(), period, snapshots),
is(true));
}
示例8: AbstractWeek
import org.joda.time.DateMidnight; //导入依赖的package包/类
public AbstractWeek(DateMidnight weekStart, DateMidnight weekEnd) {
this.weekStart = weekStart;
this.weekEnd = weekEnd;
weekInterval = new Interval(weekStart, weekEnd);
AbstractMonthView.logger.debug("Week interval: {}", weekInterval);
AbstractMonthView.logger.debug("Initializing days");
days = createDaysArray(7);
DateMidnight dayStart = weekStart;
for (int i = 0; i < 7; i++) {
DateMidnight dayEnd = dayStart.plusDays(1);
days[i] = createDay(dayStart, dayEnd);
dayStart = dayEnd;
}
}
示例9: AbstractMonth
import org.joda.time.DateMidnight; //导入依赖的package包/类
public AbstractMonth(DateMidnight referenceDateMidnight) {
logger.debug("Initializing month");
this.referenceDateMidnight = referenceDateMidnight;
logger.debug("Reference date midnight: {}", referenceDateMidnight);
monthStart = referenceDateMidnight.withDayOfMonth(1);
monthEnd = monthStart.plusMonths(1);
monthInterval = new Interval(monthStart, monthEnd);
logger.debug("Month interval: {}", monthInterval);
daysCount = Days.daysIn(monthInterval).getDays();
logger.debug("Initializing {} days", daysCount);
days = createDaysArray(daysCount);
DateMidnight dayStart = monthStart;
for (int i = 0; i < daysCount; i++) {
DateMidnight dayEnd = dayStart.plusDays(1);
days[i] = createDay(dayStart, dayEnd);
// advance to next day
dayStart = dayEnd;
}
}
示例10: GetProbeDataCommand
import org.joda.time.DateMidnight; //导入依赖的package包/类
public GetProbeDataCommand(String probeID, String token, ZibaseDeviceConfiguration configuration,
CloseableHttpAsyncClient httpClient, ObjectMapper mapper, DateMidnight... date) {
super(Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Zibase"))
.andCommandKey(HystrixCommandKey.Factory.asKey("GetProbeData"))
);
this.probeID = probeID;
if (date.length == 1) {
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy").withLocale(Locale.FRENCH);
String dateString = formatter.print(date[0]);
this.requestURL = String.format("%s?zibase=%s&token=%s&service=get&target=probe&id=%s&historic=%s",
configuration.getUrl(), configuration.getZibaseID(), token, probeID, dateString);
} else {
this.requestURL = String.format("%s?zibase=%s&token=%s&service=get&target=probe&id=%s",
configuration.getUrl(), configuration.getZibaseID(), token, probeID);
}
this.httpClient = httpClient;
this.mapper = mapper;
}
示例11: testConvertFromString
import org.joda.time.DateMidnight; //导入依赖的package包/类
@Test
public void testConvertFromString() {
Date date = new DateMidnight(2013, 12, 11).toDate();
Date seconds = new DateTime(2013, 12, 11, 5, 35, 22).toDate();
Date minutes = new DateTime(2013, 12, 11, 5, 35).toDate();
assertThat(dateConverter.fromString("2013-12-11 5:35")).isEqualTo(minutes);
assertThat(dateConverter.fromString("2013-12-11 05:35:22")).isEqualTo(seconds);
assertThat(dateConverter.fromString("2013-12-11T05:35:22")).isEqualTo(seconds);
assertThat(dateConverter.fromString("2013-12-11")).isEqualTo(date);
assertThat(dateConverter.fromString("11/12/2013")).isEqualTo(date);
assertThat(dateConverter.fromString("20131211053522")).isEqualTo(seconds);
assertThat(dateConverter.fromString("Wed Dec 11 05:35:22 2013")).isEqualTo(seconds); // ASCTIME
assertThat(dateConverter.fromString(null)).isNull();
}
示例12: testSerialization
import org.joda.time.DateMidnight; //导入依赖的package包/类
@Test
public void testSerialization() throws Exception {
RestJsonMapper mapper = new RestJsonMapper();
DatesAndTimesTo to = new DatesAndTimesTo();
to.setDate(new Date(114 /*+1900 = 2014*/, 1 /* this is februari */, 14, 10, 11, 12));
to.setLocalDate(LocalDate.of(2014, 2, 14));
to.setLocalDateTime(LocalDateTime.of(2014, 2, 14, 10, 11, 12));
to.setJodaDateTime(new DateTime(2014, 2, 14, 10, 11, 12));
to.setJodaDate(new DateMidnight(2014, 2, 14));
String res = mapper.writeValueAsString(to);
System.out.println(res);
assertThat(res).contains("\"date\":\"2014-02-14T10:11:12\"");
assertThat(res).contains("\"localDate\":\"2014-02-14\"");
assertThat(res).contains("\"localDateTime\":\"2014-02-14T10:11:12\"");
assertThat(res).contains("\"jodaDateTime\":\"2014-02-14T"); // ignore time as this changes with timezone
assertThat(res).contains("\"jodaDate\":\"2014-02-"); // ignore date as this is the date after conversion to GMT
}
示例13: ensureWorkingTimeConfigurationMustExistForPeriodOfSickNote
import org.joda.time.DateMidnight; //导入依赖的package包/类
@Test
public void ensureWorkingTimeConfigurationMustExistForPeriodOfSickNote() {
DateMidnight startDate = new DateMidnight(2015, DateTimeConstants.MARCH, 1);
DateMidnight endDate = new DateMidnight(2015, DateTimeConstants.MARCH, 10);
sickNote.setStartDate(startDate);
sickNote.setEndDate(endDate);
Mockito.when(workingTimeService.getByPersonAndValidityDateEqualsOrMinorDate(Mockito.any(Person.class),
Mockito.any(DateMidnight.class)))
.thenReturn(Optional.empty());
validator.validate(sickNote, errors);
Mockito.verify(workingTimeService).getByPersonAndValidityDateEqualsOrMinorDate(sickNote.getPerson(), startDate);
Mockito.verify(errors).reject("sicknote.error.noValidWorkingTime");
}
示例14: ensureCorrectConversionOfVacations
import org.joda.time.DateMidnight; //导入依赖的package包/类
@Test
public void ensureCorrectConversionOfVacations() throws Exception {
Application vacation1 = TestDataCreator.createApplication(TestDataCreator.createPerson("foo"),
new DateMidnight(2016, 5, 19), new DateMidnight(2016, 5, 20), DayLength.FULL);
vacation1.setStatus(ApplicationStatus.ALLOWED);
Application vacation2 = TestDataCreator.createApplication(TestDataCreator.createPerson("bar"),
new DateMidnight(2016, 4, 5), new DateMidnight(2016, 4, 10), DayLength.FULL);
Mockito.when(applicationServiceMock.getApplicationsForACertainPeriodAndState(Mockito.any(DateMidnight.class),
Mockito.any(DateMidnight.class), Mockito.any(ApplicationStatus.class)))
.thenReturn(Arrays.asList(vacation1, vacation2));
mockMvc.perform(get("/api/vacations").param("from", "2016-01-01").param("to", "2016-12-31"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.response").exists())
.andExpect(jsonPath("$.response.vacations").exists())
.andExpect(jsonPath("$.response.vacations", hasSize(2)))
.andExpect(jsonPath("$.response.vacations[0].from", is("2016-05-19")))
.andExpect(jsonPath("$.response.vacations[0].to", is("2016-05-20")))
.andExpect(jsonPath("$.response.vacations[0].person").exists())
.andExpect(jsonPath("$.response.vacations[0].person.ldapName", is("foo")));
}
示例15: setUp
import org.joda.time.DateMidnight; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
applicationService = Mockito.mock(ApplicationService.class);
nowService = Mockito.mock(NowService.class);
WorkingTimeService workingTimeService = Mockito.mock(WorkingTimeService.class);
// create working time object (MON-FRI)
WorkingTime workingTime = new WorkingTime();
List<Integer> workingDays = Arrays.asList(DateTimeConstants.MONDAY, DateTimeConstants.TUESDAY,
DateTimeConstants.WEDNESDAY, DateTimeConstants.THURSDAY, DateTimeConstants.FRIDAY);
workingTime.setWorkingDays(workingDays, DayLength.FULL);
Mockito.when(workingTimeService.getByPersonAndValidityDateEqualsOrMinorDate(Mockito.any(Person.class),
Mockito.any(DateMidnight.class)))
.thenReturn(Optional.of(workingTime));
SettingsService settingsService = Mockito.mock(SettingsService.class);
Mockito.when(settingsService.getSettings()).thenReturn(new Settings());
WorkDaysService calendarService = new WorkDaysService(new PublicHolidaysService(settingsService),
workingTimeService, settingsService);
vacationDaysService = new VacationDaysService(calendarService, nowService, applicationService);
}