Package org.joda.time.format

Examples of org.joda.time.format.DateTimeFormatter.parseDateTime()


    final DateTimeFormatter fmt = ISODateTimeFormat.dateTimeParser().withZone(PFUserContext.getDateTimeZone());
    final DateMidnight start = fmt.parseDateTime(r.getRequestParameters().getParameterValue("start").toString())
        .toDateMidnight();
    final DateMidnight end = fmt.parseDateTime(r.getRequestParameters().getParameterValue("end").toString())
        .toDateMidnight();
    final DateMidnight visibleStart = fmt.parseDateTime(
        r.getRequestParameters().getParameterValue("visibleStart").toString()).toDateMidnight();
    final DateMidnight visibleEnd = fmt
        .parseDateTime(r.getRequestParameters().getParameterValue("visibleEnd").toString()).toDateMidnight();
    final View view = new View(type, start, end, visibleStart, visibleEnd);
    final CalendarResponse response = new CalendarResponse(getCalendar(), target);
View Full Code Here


        .toDateMidnight();
    final DateMidnight end = fmt.parseDateTime(r.getRequestParameters().getParameterValue("end").toString())
        .toDateMidnight();
    final DateMidnight visibleStart = fmt.parseDateTime(
        r.getRequestParameters().getParameterValue("visibleStart").toString()).toDateMidnight();
    final DateMidnight visibleEnd = fmt
        .parseDateTime(r.getRequestParameters().getParameterValue("visibleEnd").toString()).toDateMidnight();
    final View view = new View(type, start, end, visibleStart, visibleEnd);
    final CalendarResponse response = new CalendarResponse(getCalendar(), target);
    onViewDisplayed(view, response);
  }
View Full Code Here

    Object constant = node.getState();
    if (info.isJodaType()) {
      DateTimeFormatter fmt;
      if (info.getClassType().getName().equals("org.joda.time.DateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        DateTime dateTime = fmt.parseDateTime(constant.toString());
        return StandardConverters.convertToBytes(dateTime);
      } else if (info.getClassType().getName().equals("org.joda.time.LocalDateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        LocalDateTime localDateTime = fmt.parseLocalDateTime(constant.toString());
        return StandardConverters.convertToBytes(localDateTime);
View Full Code Here

    assertThat(dt1.getYear()).isEqualTo(1978);
    DateTime dt2 = new DateTime("1978-06-01T12:10:08");
    assertThat(dt2.getYear()).isEqualTo(1978);

    // 第二种方法,使用Formatter
    DateTime dt3 = fmt.parseDateTime(dateString);
    assertThat(dt3.getYear()).isEqualTo(1978);

  }

  @Test
View Full Code Here

    {
        final DateTimeFormatter formatter = getFormatter();
        final String value = data.getInstance().getNode().textValue();

        try {
            formatter.parseDateTime(value);
        } catch (IllegalArgumentException ignored) {
            report.error(newMsg(data, bundle, "err.format.invalidDate")
                .putArgument("value", value).putArgument("expected", format));
        }
    }
View Full Code Here

    Object constant = node.getState();
    if (info.isJodaType()) {
      DateTimeFormatter fmt;
      if (info.getClassType().getName().equals("org.joda.time.DateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        DateTime dateTime = fmt.parseDateTime(constant.toString());
        return StandardConverters.convertToBytes(dateTime);
      } else if (info.getClassType().getName().equals("org.joda.time.LocalDateTime")) {
        fmt = ISODateTimeFormat.dateTime();
        LocalDateTime localDateTime = fmt.parseLocalDateTime(constant.toString());
        return StandardConverters.convertToBytes(localDateTime);
View Full Code Here

      dt.setZone(getTimeZone());
      return dt.toDate();
    }
    else
    {
      return format.parseDateTime(value).toDate();
    }
  }

  /**
   * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object,
View Full Code Here

    public static LocalDate parseLocalDate(final String stringDate, final String pattern) {

        try {
            final DateTimeFormatter dateStringFormat = DateTimeFormat.forPattern(pattern);
            final DateTime dateTime = dateStringFormat.parseDateTime(stringDate);
            return dateTime.toLocalDate();
        } catch (final IllegalArgumentException e) {
            final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
            final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.pattern", "The parameter date ("
                    + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
View Full Code Here

    }
    else
    {
      try
      {
        DateTime date = format.parseDateTime(value);
        return date.toDate();
      }
      catch (RuntimeException e)
      {
        throw new ConversionException(e);
View Full Code Here

                        for (int j = 0; j < eventListNodes.getLength(); j++) {
                            Node n = eventListNodes.item(j);
                            if (n.getNodeName().equals("eventTime")) {
                                DateTimeFormatter dtf = DateTimeFormat
                                        .forPattern("yyyy-MM-dd'T'HH:mm:ss");
                                pe.dateTime = dtf.parseDateTime(n.getTextContent());
                            } else if (n.getNodeName().equals("eventDescription")) {
                                pe.description = n.getTextContent();
                            }
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.