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));
}
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));
}
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));
}
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;
}
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());
}
Aggregations