当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.now方法代码示例

本文整理汇总了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();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:26,代码来源:EnrolmentControllerTest.java

示例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()))
        );
    }
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:17,代码来源:InstantValidator.java

示例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();
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:20,代码来源:TodoHabitDataSource.java

示例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);
        }

    }
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:21,代码来源:RpErrorResponseGeneratorService.java

示例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);
 
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:30,代码来源:FoodsApiControllerTest.java

示例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));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DurationMeasurementImpl.java

示例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();
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:33,代码来源:SpotifyApiImpl.java

示例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());
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:11,代码来源:CucumberHooksUT.java

示例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());
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:30,代码来源:NotificationCardViewHolder.java

示例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);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:15,代码来源:HubAttributeQueryRequestBuilder.java

示例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;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:11,代码来源:JournalViewActivity.java

示例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);

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:12,代码来源:MagpieFragment.java

示例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());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:13,代码来源:MatchingServiceHealthcheckRequestGeneratorService.java

示例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;
}
 
开发者ID:KevinLiddle,项目名称:crockpod,代码行数:11,代码来源:Alarm.java


注:本文中的org.joda.time.DateTime.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。