use of org.joda.time.format.DateTimeFormatter in project joda-time by JodaOrg.
the class AbstractInterval method toString.
/**
* Output a string in ISO8601 interval format.
* <p>
* From version 2.1, the string includes the time zone offset.
*
* @return re-parsable string (in the default zone)
*/
public String toString() {
DateTimeFormatter printer = ISODateTimeFormat.dateTime();
printer = printer.withChronology(getChronology());
StringBuffer buf = new StringBuffer(48);
printer.printTo(buf, getStartMillis());
buf.append('/');
printer.printTo(buf, getEndMillis());
return buf.toString();
}
use of org.joda.time.format.DateTimeFormatter in project joda-time by JodaOrg.
the class GJChronology method toString.
// Output
//-----------------------------------------------------------------------
/**
* Gets a debugging toString.
*
* @return a debugging string
*/
public String toString() {
StringBuffer sb = new StringBuffer(60);
sb.append("GJChronology");
sb.append('[');
sb.append(getZone().getID());
if (iCutoverMillis != DEFAULT_CUTOVER.getMillis()) {
sb.append(",cutover=");
DateTimeFormatter printer;
if (withUTC().dayOfYear().remainder(iCutoverMillis) == 0) {
printer = ISODateTimeFormat.date();
} else {
printer = ISODateTimeFormat.dateTime();
}
printer.withChronology(withUTC()).printTo(sb, iCutoverMillis);
}
if (getMinimumDaysInFirstWeek() != 4) {
sb.append(",mdfw=");
sb.append(getMinimumDaysInFirstWeek());
}
sb.append(']');
return sb.toString();
}
use of org.joda.time.format.DateTimeFormatter in project drill by apache.
the class JodaDateValidatorTest method parseDateFromPostgres.
private DateTime parseDateFromPostgres(String date, String pattern) {
String jodaFormat = toJodaFormat(pattern);
DateTimeFormatter format = forPattern(jodaFormat);
return parse(date, format).withZoneRetainFields(DateTimeZone.UTC);
}
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 lucene-solr by apache.
the class ParsingFieldUpdateProcessorsTest method testFailedParseMixedDate.
public void testFailedParseMixedDate() throws Exception {
IndexSchema schema = h.getCore().getLatestSchema();
assertNull(schema.getFieldOrNull("not_in_schema"));
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateOptionalTimeParser().withZoneUTC();
Map<Object, Object> mixed = new HashMap<>();
String[] dateStrings = { "2020-05-13T18:47", "1989-12-14", "1682-07-22T18:33:00.000Z" };
for (String dateString : dateStrings) {
mixed.put(dateTimeFormatter.parseDateTime(dateString).toDate(), dateString);
}
Double extraDouble = 29.554d;
// Double-typed field value
mixed.put(extraDouble, extraDouble);
SolrInputDocument d = processAdd("parse-date-no-run-processor", doc(f("id", "7201"), f("not_in_schema", mixed.values())));
assertNotNull(d);
boolean foundDouble = false;
for (Object o : d.getFieldValues("not_in_schema")) {
if (extraDouble == o) {
foundDouble = true;
} else {
assertTrue(o instanceof String);
}
mixed.values().remove(o);
}
assertTrue(foundDouble);
assertTrue(mixed.isEmpty());
}
Aggregations