本文整理汇总了Java中org.joda.time.format.ISODateTimeFormat.dateTimeParser方法的典型用法代码示例。如果您正苦于以下问题:Java ISODateTimeFormat.dateTimeParser方法的具体用法?Java ISODateTimeFormat.dateTimeParser怎么用?Java ISODateTimeFormat.dateTimeParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.format.ISODateTimeFormat
的用法示例。
在下文中一共展示了ISODateTimeFormat.dateTimeParser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDateRace
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@Test
public void testDateRace() {
Clock mockClock = mock(Clock.class);
DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser();
long two = parser.parseMillis("2013-04-21T02:59:59-00:00");
long three = parser.parseMillis("2013-04-21T03:00:00-00:00");
when(mockClock.currentTimeMillis()).thenReturn(two, three);
// save & modify static state (yuck)
Clock origClock = BucketPath.getClock();
BucketPath.setClock(mockClock);
String pat = "%H:%M";
String escaped = BucketPath.escapeString(pat,
new HashMap<String, String>(),
TimeZone.getTimeZone("UTC"), true, Calendar.MINUTE, 10, true);
// restore static state
BucketPath.setClock(origClock);
Assert.assertEquals("Race condition detected", "02:50", escaped);
}
示例2: testRfc5424DateParsing
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
@Test
public void testRfc5424DateParsing() {
final String[] examples = {
"1985-04-12T23:20:50.52Z", "1985-04-12T19:20:50.52-04:00",
"2003-10-11T22:14:15.003Z", "2003-08-24T05:14:15.000003-07:00",
"2012-04-13T11:11:11-08:00", "2012-04-13T08:08:08.0001+00:00",
"2012-04-13T08:08:08.251+00:00"
};
SyslogParser parser = new SyslogParser();
DateTimeFormatter jodaParser = ISODateTimeFormat.dateTimeParser();
for (String ex : examples) {
Assert.assertEquals(
"Problem parsing date string: " + ex,
jodaParser.parseMillis(ex),
parser.parseRfc5424Date(ex));
}
}
示例3: postProcessSlots
import org.joda.time.format.ISODateTimeFormat; //导入方法依赖的package包/类
private Set<TimeSlot> postProcessSlots(JsonNode node, String date, Exam exam, User user) {
// Filter out slots that user has a conflicting reservation with
if (node.isArray()) {
ArrayNode root = (ArrayNode) node;
LocalDate searchDate = LocalDate.parse(date, ISODateTimeFormat.dateParser());
// users reservations starting from now
List<Reservation> reservations = Ebean.find(Reservation.class)
.fetch("enrolment.exam")
.where()
.eq("user", user)
.gt("startAt", searchDate.toDate())
.findList();
DateTimeFormatter dtf = ISODateTimeFormat.dateTimeParser();
Stream<JsonNode> stream = StreamSupport.stream(root.spliterator(), false);
Map<Interval, Optional<Integer>> map = stream.collect(Collectors.toMap(n -> {
DateTime start = dtf.parseDateTime(n.get("start").asText());
DateTime end = dtf.parseDateTime(n.get("end").asText());
return new Interval(start, end);
}, n -> Optional.of(n.get("availableMachines").asInt()),
(u, v) -> {
throw new IllegalStateException(String.format("Duplicate key %s", u));
},
LinkedHashMap::new));
return handleReservations(map, reservations, exam, null, user);
}
return Collections.emptySet();
}