Search in sources :

Example 86 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project joda-time by JodaOrg.

the class TestLocalDate_Constructors method testParse_formatter.

public void testParse_formatter() throws Throwable {
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy--dd MM").withChronology(ISOChronology.getInstance(PARIS));
    assertEquals(new LocalDate(2010, 6, 30), LocalDate.parse("2010--30 06", f));
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Example 87 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project joda-time by JodaOrg.

the class TestLocalTime_Constructors method testParse_formatter.

public void testParse_formatter() throws Throwable {
    DateTimeFormatter f = DateTimeFormat.forPattern("HH mm").withChronology(ISOChronology.getInstance(PARIS));
    assertEquals(new LocalTime(13, 30), LocalTime.parse("13 30", f));
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Example 88 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project joda-time by JodaOrg.

the class TestMutableDateTime_Constructors method testParse_formatter.

public void testParse_formatter() throws Throwable {
    DateTimeFormatter f = DateTimeFormat.forPattern("yyyy--dd MM HH").withChronology(ISOChronology.getInstance(PARIS));
    assertEquals(new MutableDateTime(2010, 6, 30, 13, 0, 0, 0, ISOChronology.getInstance(PARIS)), MutableDateTime.parse("2010--30 06 13", f));
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter)

Example 89 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project drill by apache.

the class DateUtility method getDateTimeFormatter.

// 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;
}
Also used : DateTimeParser(org.joda.time.format.DateTimeParser) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeFormatterBuilder(org.joda.time.format.DateTimeFormatterBuilder)

Example 90 with DateTimeFormatter

use of org.joda.time.format.DateTimeFormatter in project opennms by OpenNMS.

the class XmlCollector3GPPTest method testTimeParser.

/**
 * Test time parser.
 *
 * @throws Exception the exception
 */
@Test
public void testTimeParser() throws Exception {
    String pattern = "yyyy-MM-dd'T'HH:mm:ssZ";
    String value = "2011-10-25T00:45:00-05:00";
    long expectedTimestamp = 1319521500000l;
    DateTimeFormatter dtf = DateTimeFormat.forPattern(pattern);
    DateTime dateTime = dtf.parseDateTime(value);
    Date date = dateTime.toDate();
    Assert.assertEquals(expectedTimestamp, date.getTime());
    MockDefaultVTDXmlCollectionHandler handler = new MockDefaultVTDXmlCollectionHandler();
    date = handler.getTimeStamp(MockDocumentBuilder.getVTDXmlDocument(), getConfigDao().getDataCollectionByName("3GPP").getXmlSources().get(0).getXmlGroups().get(0));
    Assert.assertEquals(expectedTimestamp, date.getTime());
}
Also used : DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateTimeFormatter (org.joda.time.format.DateTimeFormatter)209 DateTime (org.joda.time.DateTime)95 Date (java.util.Date)40 Test (org.junit.Test)25 DateTimeZone (org.joda.time.DateTimeZone)19 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 SolrInputDocument (org.apache.solr.common.SolrInputDocument)12 IndexSchema (org.apache.solr.schema.IndexSchema)12 DateTimeFormatterBuilder (org.joda.time.format.DateTimeFormatterBuilder)12 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)10 IOException (java.io.IOException)9 Calendar (java.util.Calendar)8 Map (java.util.Map)8 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)7 FormatDateTimeFormatter (org.elasticsearch.common.joda.FormatDateTimeFormatter)7 Test (org.testng.annotations.Test)7 TimeSpec (com.linkedin.thirdeye.api.TimeSpec)6 FilterType (net.opengis.filter.v_1_1_0.FilterType)6 Deployment (org.activiti.engine.test.Deployment)6