Package org.joda.time.format

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


  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

    // 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

    // 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

    // 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

    // 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

TOP

Related Classes of org.joda.time.format.DateTimeParser

Copyright © 2018 www.massapicom. 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.