當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTime.parse方法代碼示例

本文整理匯總了Java中org.joda.time.DateTime.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.parse方法的具體用法?Java DateTime.parse怎麽用?Java DateTime.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTime的用法示例。


在下文中一共展示了DateTime.parse方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleProgress

import org.joda.time.DateTime; //導入方法依賴的package包/類
private SpeechletResponse handleProgress(IntentRequest request, Session session) {
  checkCalendarName(request, session);

  if(allSlotsFilled(request)) {
    final String title = collectSummary(request);
    final DateTime from = DateTime.parse(
        sv(request, SLOT_DATE_FROM) + "T" + sv(request, SLOT_TIME_FROM));
    final DateTime to = getTimeTo(request, from);

    final String dateFormat = messageService.de("event.new.card.content.time.format");
    session.setAttribute(SESSION_DATE_FORMAT, dateFormat);
    session.setAttribute(SESSION_FROM, from.toString(dateFormat));
    session.setAttribute(SESSION_TO, to.toString(dateFormat));

    final OutputSpeech speech = speechService.confirmNewEvent(title, from, to, request.getLocale());
    return SpeechletResponse.newDialogConfirmIntentResponse(speech);
  }

  //normally we want to delegate because we have defined the dialog into the model on alexa
  if( request.getDialogState() != DialogState.COMPLETED) {
    Intent updatedIntent = updateIntent(request.getIntent());
    return SpeechletResponse.newDialogDelegateResponse(updatedIntent);
  }

  return SpeechletResponse.newTellResponse(speechService.speechCancelNewEvent(request.getLocale()));
}
 
開發者ID:rainu,項目名稱:alexa-skill,代碼行數:27,代碼來源:NewEventSpeechlet.java

示例2: dateTimeValidWithServiceResponseAsync

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * Get '2012-01-01T01:01:01Z' as date-time.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the {@link ServiceResponse} object if successful.
 */
public Observable<ServiceResponse<Void>> dateTimeValidWithServiceResponseAsync() {
    final DateTime dateTimeQuery = DateTime.parse("2012-01-01T01:01:01Z");
    return service.dateTimeValid(dateTimeQuery)
        .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
            @Override
            public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                try {
                    ServiceResponse<Void> clientResponse = dateTimeValidDelegate(response);
                    return Observable.just(clientResponse);
                } catch (Throwable t) {
                    return Observable.error(t);
                }
            }
        });
}
 
開發者ID:Azure,項目名稱:autorest.java,代碼行數:22,代碼來源:QueriesImpl.java

示例3: logSessionTimeoutEvent_shouldSendEvent

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Test
public void logSessionTimeoutEvent_shouldSendEvent() throws Exception {
    EventSinkHubEventLogger eventLogger = new EventSinkHubEventLogger(serviceInfo, eventSinkProxy);
    ArgumentCaptor<EventSinkHubEvent> eventCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    SessionId sessionId = aSessionId().build();
    DateTime sessionExpiryTimestamp = DateTime.now().minusMinutes(10);
    String transactionEntityId = "Some entity id";

    eventLogger.logSessionTimeoutEvent(sessionId, sessionExpiryTimestamp, transactionEntityId, null);

    verify(eventSinkProxy).logHubEvent(eventCaptor.capture());

    EventSinkHubEvent actualEvent = eventCaptor.getValue();
    assertThat(actualEvent.getEventType()).isEqualTo(SESSION_EVENT);
    assertThat(actualEvent.getDetails().containsKey(session_event_type)).as("Message details does not contain an entry for Session Event Type.").isTrue();
    assertThat(actualEvent.getDetails().get(session_event_type)).isEqualTo(SESSION_TIMEOUT);

    String actualExpiryTimeString = actualEvent.getDetails().get(session_expiry_time);
    DateTime actualExpiryTime = DateTime.parse(actualExpiryTimeString);
    assertThat(actualExpiryTime.isEqual(sessionExpiryTimestamp)).as(MessageFormat.format("Expected timestamp {0} but got {1}", sessionExpiryTimestamp, actualExpiryTime)).isTrue();

    assertThat(actualEvent.getDetails().containsKey(transaction_entity_id)).as("Message details does not contain an entry for Transaction Entity Id").isEqualTo(actualEvent.getDetails().containsKey(transaction_entity_id));
    assertThat(actualEvent.getDetails().get(transaction_entity_id)).isEqualTo(transactionEntityId);
}
 
開發者ID:alphagov,項目名稱:verify-hub,代碼行數:25,代碼來源:EventSinkHubEventLoggerTest.java

示例4: equivalentTo

import org.joda.time.DateTime; //導入方法依賴的package包/類
public static Matcher<String> equivalentTo(DateTime expected) {
  return new TypeSafeMatcher<String>() {
    @Override
    public void describeTo(Description description) {
      description.appendText(String.format(
        "a date time matching: %s", expected.toString()));
    }

    @Override
    protected boolean matchesSafely(String textRepresentation) {
      //response representation might vary from request representation
      DateTime actual = DateTime.parse(textRepresentation);

      return expected.isEqual(actual);
    }
  };
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:18,代碼來源:TextDateTimeMatcher.java

示例5: reloadFrom

import org.joda.time.DateTime; //導入方法依賴的package包/類
public void reloadFrom(final List<Trip> data) {
    current.clear();
    past.clear();
    future.clear();
    for (Trip t : data) {
        DateTime begDate = DateTime.parse(t.getStartDate());
        DateTime endDate = DateTime.parse(t.getEndDate());
        if (begDate.isAfterNow()) {
            future.add(t);
        } else if (endDate.isBeforeNow()) {
            past.add(t);
        } else {
            current.add(t);
        }
    }
    notifyDataSetChanged();
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:18,代碼來源:JournalAdapter.java

示例6: getTimeTo

import org.joda.time.DateTime; //導入方法依賴的package包/類
private DateTime getTimeTo(IntentRequest request, DateTime from) {
  final String sDuration = sv(request, SLOT_DURATION);
  final String sDateFrom = sv(request, SLOT_DATE_FROM);
  final String sDateTo = sv(request, SLOT_DATE_TO);
  final String sTimeTo = sv(request, SLOT_TIME_TO);

  if(sTimeTo != null) {
    if(sDateTo != null) {
      return DateTime.parse(sDateTo + "T" + sTimeTo);
    }

    return DateTime.parse(sDateFrom + "T" + sTimeTo);
  } else if(sDateTo != null) {
    return DateTime.parse(sDateTo).withTimeAtStartOfDay();
  }

  final Duration duration = Duration.parse(sDuration);
  return from.plus(duration.toMillis());
}
 
開發者ID:rainu,項目名稱:alexa-skill,代碼行數:20,代碼來源:NewEventSpeechlet.java

示例7: get

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public Object get(final String name,
                  final Document document) {
    final IndexableField stringDateTime = document.getField(name);

    if (stringDateTime != null) {
        return DateTime.parse(stringDateTime.stringValue(), DateTimeFormat.forPattern(DATETIME_FORMAT));
    } else {
        return null;
    }
}
 
開發者ID:mhaddon,項目名稱:Sound.je,代碼行數:12,代碼來源:JodaDateTimeSplitBridge.java

示例8: reportStudentActivity

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Restrict({@Group("ADMIN")})
public Result reportStudentActivity(Long studentId, String from, String to) throws IOException {

    final DateTime start = DateTime.parse(from, DTF);
    final DateTime end = DateTime.parse(to, DTF);

    User student = Ebean.find(User.class, studentId);
    if (student == null) {
        return notFound("sitnet_error_not_found");
    }

    List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
            .fetch("exam")
            .where()
            .gt("started", start)
            .lt("ended", end)
            .eq("user.id", studentId)
            .findList();

    Workbook wb = new XSSFWorkbook();
    Sheet studentSheet = wb.createSheet("student");
    String[] studentHeaders = {"id", "first name", "last name", "email", "language"};
    addHeader(studentSheet, studentHeaders);
    Row dataRow = studentSheet.createRow(1);
    int index = 0;
    dataRow.createCell(index++).setCellValue(student.getId());
    dataRow.createCell(index++).setCellValue(student.getFirstName());
    dataRow.createCell(index++).setCellValue(student.getLastName());
    dataRow.createCell(index++).setCellValue(student.getEmail());
    dataRow.createCell(index).setCellValue(student.getLanguage().getCode());
    generateParticipationSheet(wb, participations, false);
    response().setHeader("Content-Disposition", "attachment; filename=\"student_activity.xlsx\"");
    return ok(encode(wb));
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:35,代碼來源:StatisticsController.java

示例9: DeviceServiceModel

import org.joda.time.DateTime; //導入方法依賴的package包/類
public DeviceServiceModel(final Device device, final DeviceTwinServiceModel twin, String iotHubHostName) {
    this(
        device.geteTag(),
        device.getDeviceId(),
        device.getCloudToDeviceMessageCount(),
        device.getLastActivityTime() == null ? null : DateTime.parse(device.getLastActivityTime(), ISODateTimeFormat.dateTimeParser().withZoneUTC()),
        device.getConnectionState() == DeviceConnectionState.Connected,
        device.getStatus() == DeviceStatus.Enabled,
        device.getStatusUpdatedTime() == null ? null : DateTime.parse(device.getStatusUpdatedTime(), ISODateTimeFormat.dateTimeParser().withZoneUTC()),
        twin,
        new AuthenticationMechanismServiceModel(device),
        iotHubHostName);
}
 
開發者ID:Azure,項目名稱:iothub-manager-java,代碼行數:14,代碼來源:DeviceServiceModel.java

示例10: it_should_not_throw_any_exception_when_task_date_after_now

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Test
public void it_should_not_throw_any_exception_when_task_date_after_now() {
    DateTime taskDate = DateTime.parse("20200318");
    Clock.freeze(DateTime.parse("20170318"));
    ScheduleInfo scheduleInfo = new TaskSchedulerBuilder().when(taskDate).build();
    scheduleInfo.validate();
    Clock.unfreeze();
}
 
開發者ID:212data,項目名稱:cronit-repository,代碼行數:9,代碼來源:TaskSchedulerTest.java

示例11: getReservationsForRoomByDate

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Restrict({@Group("ADMIN")})
public Result getReservationsForRoomByDate(Long roomId, String from, String to) throws IOException {

    final DateTime start = DateTime.parse(from, DTF);
    final DateTime end = DateTime.parse(to, DTF);

    List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class)
            .fetch("user")
            .fetch("exam")
            .where()
            .gt("reservation.endAt", start)
            .lt("reservation.startAt", end)
            .eq("reservation.machine.room.id", roomId)
            .findList();

    Workbook wb = new XSSFWorkbook();
    Sheet sheet = wb.createSheet("reservations");
    String[] headers = {"enrolment id", "enrolled on", "user id", "user first name", "user last name", "exam id",
            "exam name", "reservation id", "reservation begins", "reservation ends", "machine id", "machine name",
            "machine IP", "room id", "room name", "room code"};

    addHeader(sheet, headers);

    for (ExamEnrolment e : enrolments) {
        List<String> data = Arrays.asList(
                Long.toString(e.getId()),
                ISODateTimeFormat.date().print(new DateTime(e.getEnrolledOn())),
                Long.toString(e.getUser().getId()),
                e.getUser().getFirstName(),
                e.getUser().getLastName(),
                Long.toString(e.getExam().getId()),
                e.getExam().getName(),
                Long.toString(e.getReservation().getId()),
                ISODateTimeFormat.dateTime().print(new DateTime(e.getReservation().getStartAt())),
                ISODateTimeFormat.dateTime().print(new DateTime(e.getReservation().getEndAt())),
                Long.toString(e.getReservation().getMachine().getId()),
                e.getReservation().getMachine().getName(),
                e.getReservation().getMachine().getIpAddress(),
                Long.toString(e.getReservation().getMachine().getRoom().getId()),
                e.getReservation().getMachine().getRoom().getName(),
                e.getReservation().getMachine().getRoom().getRoomCode()
        );
        Row dataRow = sheet.createRow(enrolments.indexOf(e) + 1);
        for (int i = 0; i < data.size(); ++i) {
            dataRow.createCell(i).setCellValue(data.get(i));
        }
    }
    IntStream.range(0, 17).forEach(i -> sheet.autoSizeColumn(i, true));
    response().setHeader("Content-Disposition", "attachment; filename=\"reservations.xlsx\"");
    return ok(encode(wb));
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:52,代碼來源:StatisticsController.java

示例12: onCreate

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_journal);
    ButterKnife.bind(this);

    Intent data = getIntent();
    if (data.hasExtra("TRIP")) {
        toolbar.setTitle("Edit Journal");
        Parcelable par = data.getParcelableExtra("TRIP");
        currentTrip = Parcels.unwrap(par);
        FirebaseAuth auth = FirebaseAuth.getInstance();
        String uid = auth.getCurrentUser().getUid();
        DatabaseReference ref = FirebaseDatabase.getInstance()
                .getReference(uid).child(currentTrip.getKey())
                .child("entries");
        photoFrag = PhotoFragment.newInstance(ref.toString());
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, photoFrag)
                .commit();
        jname.setText(currentTrip.getName());
        location.setText(currentTrip.getLocation());
        startDateView.setText(formatted(DateTime.parse(currentTrip
                .getStartDate())));
        endDateView.setText(formatted(DateTime.parse(currentTrip.getEndDate())));
        startDate = DateTime.parse(currentTrip.getStartDate());
        endDate = DateTime.parse(currentTrip.getEndDate());
    } else {
        toolbar.setTitle("New Journal");
        currentTrip = new Trip();
        DateTime today = DateTime.now();
        startDateView.setText(formatted(today));
        endDateView.setText(formatted(today.plusDays(1)));
        startDate = today;
        endDate = today.plusDays(1);
    }
    dpDialog = DatePickerDialog.newInstance(this,
            startDate.getYear(), startDate.getMonthOfYear() - 1, startDate
                    .getDayOfMonth());

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:45,代碼來源:TripEditorActivity.java

示例13: populateItemViewHolder

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
protected void populateItemViewHolder(EntryHolder viewHolder,
                                      JournalEntry __unused__,
                                      int section, int secPos,
                                      int listPos) {
    String thisKey = (String) entryMap.keySet().toArray()[section];
    JournalEntry model = entryMap.get(thisKey).get(secPos);
    if (!seenDates.contains(thisKey)) {
        seenDates.add(thisKey);
        DateTime entryDate = DateTime.parse(model.getDate());
        final DateTime midDay = entryDate.withTimeAtStartOfDay().plusHours(12);
        /* fetch weather data if midDay is a new insert */
        fetchWeatherForDate(model.getLat(), model.getLng(),
                midDay);
    }
    viewHolder.setCaption(model.getCaption());
    viewHolder.setDate(model.getDate());

    switch (model.getType()) {
        case 1:
            viewHolder.mediaContainer.setVisibility(View
                    .GONE);
            break;
        case 2: // photo
            viewHolder.topImage.setVisibility(View.VISIBLE);
            viewHolder.playIcon.setVisibility(View.GONE);
            Glide.with(viewHolder.topImage.getContext())
                    .using(imgLoader)
                    .load(storage.getReferenceFromUrl(model.getUrl()))
                    .into(viewHolder.topImage);
            break;
        case 3: // audio
            viewHolder.topImage.setVisibility(View.VISIBLE);
            viewHolder.playIcon.setVisibility(View.VISIBLE);
            break;
        case 4: // video
            viewHolder.topImage.setVisibility(View.VISIBLE);
            viewHolder.playIcon.setVisibility(View.VISIBLE);
            Glide.with(viewHolder.topImage.getContext())
                    .using(imgLoader)
                    .load(storage.getReferenceFromUrl
                            (model.getThumbnailUrl()))
                    .into(viewHolder.topImage);
            break;
        default:
            viewHolder.topImage.setVisibility(View.GONE);
            break;
    }
    viewHolder.editBtn.setOnClickListener( view -> {
        String key = getRef(listPos).getKey();
        toMediaEdit(model, key);
    });
    viewHolder.topImage.setOnClickListener( view -> {
        toMediaView(model);
    });
    viewHolder.playIcon.setOnClickListener( view -> {
        toMediaView(model);
    });
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:60,代碼來源:JournalViewActivity.java

示例14: getDateTimeProperty

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public DateTime getDateTimeProperty(String name) {
    return DateTime.parse(getStringProperty(name));
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:5,代碼來源:MapModuleConfig.java

示例15: deserialize

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public NetworkMetadata deserialize(JsonParser parser, DeserializationContext deserializationContext) throws IOException {
    String id = null;
    String sourceFormat = null;
    DateTime caseDate = null;
    int forecastDistance = 0;

    List<Extension<NetworkMetadata>> extensions = Collections.emptyList();

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        switch (parser.getCurrentName()) {
            case "id":
                id = parser.nextTextValue();
                break;

            case "sourceFormat":
                sourceFormat = parser.nextTextValue();
                break;

            case "caseDate":
                caseDate = DateTime.parse(parser.nextTextValue());
                break;

            case "forecastDistance":
                forecastDistance = parser.nextIntValue(0);
                break;

            case "extensions":
                parser.nextToken();
                extensions = JsonUtil.readExtensions(parser, deserializationContext);
                break;

            default:
                throw new PowsyblException("Unexpected field: " + parser.getCurrentName());
        }
    }

    NetworkMetadata metadata = new NetworkMetadata(id, sourceFormat, caseDate, forecastDistance);
    ExtensionSupplier.addExtensions(metadata, extensions);

    return metadata;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:43,代碼來源:NetworkMetadataDeserializer.java


注:本文中的org.joda.time.DateTime.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。