Package org.elasticsearch.common.joda.time.format

Examples of org.elasticsearch.common.joda.time.format.DateTimeFormatterBuilder


* @author kimchy (Shay Banon)
*/
public class SimpleJodaTests {

    @Test public void testMultiParsers() {
        DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
        DateTimeParser[] parsers = new DateTimeParser[3];
        parsers[0] = DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getParser();
        parsers[1] = DateTimeFormat.forPattern("MM-dd-yyyy").withZone(DateTimeZone.UTC).getParser();
        parsers[2] = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZone(DateTimeZone.UTC).getParser();
        builder.append(DateTimeFormat.forPattern("MM/dd/yyyy").withZone(DateTimeZone.UTC).getPrinter(), parsers);

        DateTimeFormatter formatter = builder.toFormatter();

        formatter.parseMillis("2009-11-15 14:12:12");
    }
View Full Code Here


            } else {
                DateTimeParser[] parsers = new DateTimeParser[formats.length];
                for (int i = 0; i < formats.length; i++) {
                    parsers[i] = DateTimeFormat.forPattern(formats[i]).withZone(DateTimeZone.UTC).getParser();
                }
                DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder()
                        .append(DateTimeFormat.forPattern(formats[0]).withZone(DateTimeZone.UTC).getPrinter(), parsers);
                formatter = builder.toFormatter();
            }
        }
        return new FormatDateTimeFormatter(input, formatter.withZone(DateTimeZone.UTC));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.joda.time.format.DateTimeFormatterBuilder

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.