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


Java ISODateTimeFormat.dateTimeParser方法代碼示例

本文整理匯總了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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:23,代碼來源:TestBucketPath.java

示例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));
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:20,代碼來源:TestSyslogParser.java

示例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();
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:28,代碼來源:ExternalCalendarController.java


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