本文整理汇总了Java中org.joda.time.DateTime.now方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.now方法的具体用法?Java DateTime.now怎么用?Java DateTime.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateEnrolmentPastReservationExists
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testCreateEnrolmentPastReservationExists() throws Exception {
// Setup
reservation.setMachine(room.getExamMachines().get(0));
reservation.setStartAt(DateTime.now().minusDays(2));
reservation.setEndAt(DateTime.now().minusDays(1));
reservation.save();
DateTime enrolledOn = DateTime.now();
enrolment.setEnrolledOn(enrolledOn);
enrolment.setReservation(reservation);
enrolment.save();
// Execute
Result result = request(Helpers.POST,
String.format("/app/enroll/%s/exam/%d", exam.getCourse().getCode(), exam.getId()), null);
assertThat(result.status()).isEqualTo(200);
// Verify
List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class).findList();
assertThat(enrolments).hasSize(2);
ExamEnrolment e = enrolments.get(1);
assertThat(e.getEnrolledOn().isAfter(enrolledOn));
assertThat(e.getReservation()).isNull();
}
示例2: shouldReturnRequiredCycle3AttributesWhenValuesExistInCycle3Assertion
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void shouldReturnRequiredCycle3AttributesWhenValuesExistInCycle3Assertion(){
List<Attribute> accountCreationAttributes = Arrays.asList(CYCLE_3).stream()
.map(attributeQueryAttributeFactory::createAttribute)
.collect(toList());
ImmutableMap<String, String> build = ImmutableMap.<String, String>builder().put("cycle3Key", "cycle3Value").build();
Cycle3Dataset cycle3Dataset = Cycle3Dataset.createFromData(build);
HubAssertion hubAssertion =new HubAssertion("1", "issuerId", DateTime.now(), new PersistentId("1"), null, Optional.of(cycle3Dataset));
List<Attribute> userAttributesForAccountCreation = userAccountCreationAttributeExtractor.getUserAccountCreationAttributes(accountCreationAttributes, null, Optional.of(hubAssertion));
List<Attribute> cycle_3 = userAttributesForAccountCreation.stream().filter(a -> a.getName().equals("cycle_3")).collect(toList());
StringBasedMdsAttributeValue personName = (StringBasedMdsAttributeValue) cycle_3.get(0).getAttributeValues().get(0);
assertThat(cycle_3.size()).isEqualTo(1);
assertThat(personName.getValue().equals("cycle3Value"));
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:19,代码来源:UserAccountCreationAttributeExtractorTest.java
示例3: validate
import org.joda.time.DateTime; //导入方法依赖的package包/类
public void validate(DateTime instant, String instantName) {
Duration age = new Duration(instant, DateTime.now());
if (age.isLongerThan(MAXIMUM_INSTANT_AGE)) {
throw new SamlResponseValidationException(String.format("%s is too far in the past %s",
instantName,
PeriodFormat.getDefault().print(age.toPeriod()))
);
}
if (dateTimeComparator.isAfterNow(instant)) {
throw new SamlResponseValidationException(String.format("%s is in the future %s",
instantName,
instant.withZone(UTC).toString(dateHourMinuteSecond()))
);
}
}
示例4: onDataChange
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
DateTime now = DateTime.now();
dueHabits.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
HabitDataModel model = snapshot.getValue(HabitDataModel.class);
if (model != null) {
Habit habit = model.getHabit();
if (habit != null) {
dueHabits.add(habit);
}
}
}
recreateDataset();
}
示例5: generate
import org.joda.time.DateTime; //导入方法依赖的package包/类
public SamlMessageDto generate(RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto) {
try {
final OutboundResponseFromHub response = new OutboundResponseFromHub(
requestForErrorResponseFromHubDto.getResponseId(),
requestForErrorResponseFromHubDto.getInResponseTo(),
hubEntityId,
DateTime.now(),
TransactionIdaStatus.valueOf(requestForErrorResponseFromHubDto.getStatus().name()),
empty(),
requestForErrorResponseFromHubDto.getAssertionConsumerServiceUri());
final String errorResponse = outboundResponseFromHubToResponseTransformerFactory.get(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId()).apply(response);
return new SamlMessageDto(errorResponse);
} catch (Exception e) {
throw new UnableToGenerateSamlException("Unable to generate RP error response", e, Level.ERROR);
}
}
示例6: testFoodsPostOk
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
@WithMockAuth(id="1")
public void testFoodsPostOk() throws Exception {
Food mockFoodOk = new Food(0, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, null, true);
Settings global_settings = new Settings(1, LocalTime.MIDNIGHT, DateTime.now(), "", "", "", "", 0, 1, "", "");
given(settingsRepo.findOne(1)).willReturn(global_settings);
given(mockFoodRepository.findByNameAndArchived(mockFoodOk.getName(), false)).willReturn(null);
mockMvc.perform(post("/api/foods").content(
"{\n" +
" \"foodName\": \""+mockFoodOk.getName()+"\",\n" +
" \"foodType\": \""+foodType.convertToDatabaseColumn(mockFoodOk.getFoodType())+"\",\n" +
" \"description\": \""+mockFoodOk.getDescription()+"\",\n" +
" \"standard\": \""+mockFoodOk.isStandard()+"\",\n" +
" \"price\": "+mockFoodOk.getPrice()+"\n" +
"}"
).contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isNoContent());
verify(mockFoodRepository, times(1)).findByNameAndArchived(mockFoodOk.getName(), false);
verify(mockFoodRepository, times(1)).save(mockFoodOk);
verifyNoMoreInteractions(mockFoodRepository);
}
示例7: stop
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public void stop() {
DateTime end = DateTime.now();
long endNanos = System.nanoTime();
measuredOperation.setStart(start);
measuredOperation.setEnd(end);
measuredOperation.setTotalTime(Duration.millis((endNanos - startNanos) / 1000000L));
}
示例8: executeTokenPreflight
import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
* Update the persisted access token and the authorization header if necessary
*
* @return The id of the currently linked user
*/
@SuppressWarnings("Duplicates")
private synchronized String executeTokenPreflight() throws Exception {
AuthToken token = authTokenDao.get(TokenGroup.INTEGRATIONS, "spotify");
if (StringUtils.isEmpty(token.getToken())) {
throw new UnavailableException("The Spotify Api is not connected to an account");
}
DateTime expiryTime = token.getExpiryTime();
DateTime now = DateTime.now();
if (expiryTime != null && now.isAfter(expiryTime)) {
SpotifyOAuthFlowDirector director = new SpotifyOAuthFlowDirector(configService.getConsumerKey(), configService.getConsumerSecret(), webClient);
boolean refreshSuccess = director.awaitRefreshedAccessToken(token.getRefreshToken());
if (refreshSuccess) {
token.setToken(director.getAccessToken());
token.setIssuedAt(now);
token.setTimeToLive(director.getTimeToLive());
authTokenDao.save(token);
} else {
throw new UnavailableException("The Spotify Api failed to refresh the access token");
}
} else {
headers.put(HttpHeader.AUTHORIZATION, OAUTH_HEADER_PREFIX + token.getToken());
}
return token.getUserId();
}
示例9: setUp
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Before
public void setUp() throws InterruptedException {
DateTime now = DateTime.now();
// prepare mock
mockDataInputProvider = Mockito.mock(ExcelDataProvider.class);
PowerMockito.mockStatic(Context.class);
when(Context.getDataInputProvider()).thenReturn(mockDataInputProvider);
when(Context.getStartCurrentScenario()).thenReturn(now);
DateTimeUtils.setCurrentMillisFixed(now.plusSeconds(5).getMillis());
}
示例10: bind
import org.joda.time.DateTime; //导入方法依赖的package包/类
public void bind(NotificationPojo dataItem) {
this.dataItem = dataItem;
if (dataItem.getUsername() != null){
if(dataItem.getUsername().trim().isEmpty()){
personName.setText("Anonymous");
} else {
personName.setText(dataItem.getUsername());
}
}
DateTime now = DateTime.now();
String timeInMills= String.valueOf(System.currentTimeMillis());
String currentTimeDirect = String.valueOf(Long.parseLong(dataItem.getTime().trim()));
int currentTime = (int) (System.currentTimeMillis() - Long.parseLong(dataItem.getTime().trim()))/1000;
// Todo Write the logic to get activity as per the feeling name
notificationTime.setText(CurrentTimeLong.getCurrentTime(dataItem.getTime().trim(), itemView.getContext()));
if (dataItem.getTextStatus() != null){
if (!(dataItem.getTextStatus().trim().isEmpty())){
notification_feeling_status.setText(String.valueOf(getEmotionValue(dataItem) + " your post: " + dataItem.getTextStatus().trim()));
} else {
notification_feeling_status.setText("No status");
}
}
personPhoto.setImageURI(dataItem.getAvatarPic());
}
示例11: createHubAttributeQueryRequest
import org.joda.time.DateTime; //导入方法依赖的package包/类
public HubAttributeQueryRequest createHubAttributeQueryRequest(final AttributeQueryRequestDto attributeQueryRequestDto) {
return new HubAttributeQueryRequest(
attributeQueryRequestDto.getRequestId(),
new PersistentId(attributeQueryRequestDto.getPersistentId().getNameId()),
attributeQueryRequestDto.getEncryptedMatchingDatasetAssertion(),
attributeQueryRequestDto.getAuthnStatementAssertion(),
createCycle3Assertion(attributeQueryRequestDto),
attributeQueryRequestDto.getUserAccountCreationAttributes(),
DateTime.now(),
attributeQueryRequestDto.getAssertionConsumerServiceUri(),
attributeQueryRequestDto.getAuthnRequestIssuerEntityId(),
AuthnContext.valueOf(attributeQueryRequestDto.getLevelOfAssurance().name()),
hubEntityId);
}
示例12: createFileName
import org.joda.time.DateTime; //导入方法依赖的package包/类
private File createFileName(String prefix, String ext) throws
IOException {
DateTime now = DateTime.now();
DateTimeFormatter fmt = DateTimeFormat.forPattern
("yyyyMMdd-HHmmss");
File cacheDir = getExternalCacheDir();
File media = File.createTempFile(prefix + "-" + fmt.print(now),
ext, cacheDir);
return media;
}
示例13: onDateSet
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public void onDateSet(CalendarDatePickerDialog calendarDatePickerDialog,
int year, int monthOfYear, int dayOfMonth) {
FragmentManager fm = ((PublisherActivity) getActivity()).getSupportFragmentManager();
timestamp.setDate(year, monthOfYear + 1, dayOfMonth);
DateTime now = DateTime.now();
RadialTimePickerDialog radialTimePickerDialog = RadialTimePickerDialog
.newInstance(this, now.getHourOfDay(), now.getMinuteOfHour(), true);
radialTimePickerDialog.show(fm, FRAG_TAG_TIME_PICKER);
}
示例14: generate
import org.joda.time.DateTime; //导入方法依赖的package包/类
public SamlMessageDto generate(MatchingServiceHealthCheckerRequestDto dto) {
MatchingServiceHealthCheckRequest matchingServiceRequest = new MatchingServiceHealthCheckRequest(
MessageFormat.format("healthcheck-request-{0}", UUID.randomUUID().toString()),
DateTime.now(),
new PersistentId("healthcheck-pid"),
URI.create(""),
dto.getTransactionEntityId(),
hubEntityId
);
return attributeQueryGenerator.createAttributeQueryContainer(matchingServiceRequest, dto.getMatchingServiceEntityId());
}
示例15: getNextTriggerTime
import org.joda.time.DateTime; //导入方法依赖的package包/类
public DateTime getNextTriggerTime() {
DateTime now = DateTime.now();
DateTime target = now
.withHourOfDay(getHourOfDay())
.withMinuteOfHour(getMinute())
.withSecondOfMinute(0)
.withMillisOfSecond(0);
return target.isBefore(now) ? target.plus(REPEAT_DURATION) : target;
}