Examples of DateTimeParser


Examples of org.apache.james.mime4j.field.datetime.parser.DateTimeParser

                   
                    if (f instanceof DateTimeField) {
                        // We need to make sure we convert it to GMT
                        final StringReader reader = new StringReader(f.getBody());
                        try {
                            DateTime dateTime = new DateTimeParser(reader).parseAll();
                            Calendar cal = getGMT();
                            cal.set(dateTime.getYear(), dateTime.getMonth() - 1, dateTime.getDay(), dateTime.getHour(), dateTime.getMinute(), dateTime.getSecond());
                            sentDate =  cal.getTime();
                           
                        } catch (org.apache.james.mime4j.field.datetime.parser.ParseException e) {
View Full Code Here

Examples of org.apache.james.mime4j.field.datetime.parser.DateTimeParser

            monitor.warn("Parsing " + paramName + " null", "returning null");
            return null;
        }

        try {
            return new DateTimeParser(new StringReader(value)).parseAll()
                    .getDate();
        } catch (org.apache.james.mime4j.field.datetime.parser.ParseException e) {
            if (monitor.isListening()) {
                monitor.warn(paramName + " parameter is invalid: " + value,
                        paramName + " parameter is ignored");
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

     * @return A DateTimeFormatter suitable to parse an ES_DATE_FORMAT formatted string to a
     *         DateTime Object even if it contains no milliseconds.
     */
    public static DateTimeFormatter timeFormatterWithOptionalMilliseconds() {
        // This is the .SSS part
        DateTimeParser ms = new DateTimeFormatterBuilder()
                .appendLiteral(".")
                .appendFractionOfSecond(1,3)
                .toParser();

        return new DateTimeFormatterBuilder()
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

  private static DateTime parseIgnoreTrailingCharacters(DateTimeFormatter formatter, String text) {
    // this is a modified version of DateTimeFormatter.parseDateTime() that does not
    // throw an exception on trailing characters
   
    Chronology chronology = DateTimeUtils.getChronology(null);
    DateTimeParser parser = formatter.getParser();
   
    Locale locale = null;
    Integer pivotYear = null;
    int defaultYear = 2000;
    DateTimeZone timeZone = null;
   
    DateTimeParserBucket bucket = new DateTimeParserBucket(0, chronology, locale, pivotYear, defaultYear);
    int newPos = parser.parseInto(bucket, text, 0);
    if (newPos >= 0) {
      long millis = bucket.computeMillis(true, text);
      if (formatter.isOffsetParsed() && bucket.getOffsetInteger() != null) {
        int parsedOffset = bucket.getOffsetInteger();
        DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset);
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

    // Function returns the date time formatter used to parse date strings
    public static DateTimeFormatter getDateTimeFormatter() {

        if (dateTimeTZFormat == null) {
            DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
            DateTimeParser optionalTime = DateTimeFormat.forPattern(" HH:mm:ss").getParser();
            DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
            DateTimeParser optionalZone = DateTimeFormat.forPattern(" ZZZ").getParser();

            dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime).appendOptional(optionalSec).appendOptional(optionalZone).toFormatter();
        }

        return dateTimeTZFormat;
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

    // Function returns time formatter used to parse time strings
    public static DateTimeFormatter getTimeFormatter() {
        if (timeFormat == null) {
            DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm:ss");
            DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
            timeFormat = new DateTimeFormatterBuilder().append(timeFormatter).appendOptional(optionalSec).toFormatter();
        }
        return timeFormat;
    }
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

    // Function returns the date time formatter used to parse date strings
    public static DateTimeFormatter getDateTimeFormatter() {

        if (dateTimeTZFormat == null) {
            DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
            DateTimeParser optionalTime = DateTimeFormat.forPattern(" HH:mm:ss").getParser();
            DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
            DateTimeParser optionalZone = DateTimeFormat.forPattern(" ZZZ").getParser();

            dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime).appendOptional(optionalSec).appendOptional(optionalZone).toFormatter();
        }

        return dateTimeTZFormat;
View Full Code Here

Examples of org.joda.time.format.DateTimeParser

    // Function returns time formatter used to parse time strings
    public static DateTimeFormatter getTimeFormatter() {
        if (timeFormat == null) {
            DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm:ss");
            DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser();
            timeFormat = new DateTimeFormatterBuilder().append(timeFormatter).appendOptional(optionalSec).toFormatter();
        }
        return timeFormat;
    }
View Full Code Here

Examples of org.springframework.format.datetime.joda.DateTimeParser

      public LocalDate convert(DateTime source) {
        return source.toLocalDate();
      }
    });
    formattingService.addFormatterForFieldType(LocalDate.class, new ReadablePartialPrinter(DateTimeFormat
        .shortDate()), new DateTimeParser(DateTimeFormat.shortDate()));
    String formatted = formattingService.convert(new LocalDate(2009, 10, 31), String.class);
    assertEquals("10/31/09", formatted);
    LocalDate date = formattingService.convert("10/31/09", LocalDate.class);
    assertEquals(new LocalDate(2009, 10, 31), date);
  }
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.