本文整理汇总了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()));
}
示例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);
}
}
});
}
示例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);
}
示例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);
}
};
}
示例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();
}
示例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());
}
示例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;
}
}
示例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));
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
示例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);
});
}
示例14: getDateTimeProperty
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public DateTime getDateTimeProperty(String name) {
return DateTime.parse(getStringProperty(name));
}
示例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;
}