/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
public FilterPeriod(Optional<String> startDateAsString, Optional<String> endDateAsString) { Assert.notNull(startDateAsString, "Start date must be given"); Assert.notNull(endDateAsString, "End date must be given"); // Set default values for dates int currentYear = DateMidnight.now().getYear(); this.startDate = DateUtil.getFirstDayOfYear(currentYear); this.endDate = DateUtil.getLastDayOfYear(currentYear); // Override default values with parsed dates DateTimeFormatter formatter = DateTimeFormat.forPattern(DateFormat.PATTERN); if (startDateAsString.isPresent()) { this.startDate = DateMidnight.parse(startDateAsString.get(), formatter); } if (endDateAsString.isPresent()) { this.endDate = DateMidnight.parse(endDateAsString.get(), formatter); } Assert.isTrue(endDate.isAfter(startDate) || endDate.isEqual(startDate), "Start date must be before end date"); }
public void eval() { // Get the input byte[] buf1 = new byte[left.end - left.start]; left.buffer.getBytes(left.start, buf1, 0, left.end - left.start); String input = new String(buf1, com.google.common.base.Charsets.UTF_8); out.value = (org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC)).getMillis(); } }
public void eval() { if (left.isSet == 0 || left.start == left.end) { out.isSet = 0; return; } out.isSet = 1; // Get the input byte[] buf1 = new byte[left.end - left.start]; left.buffer.getBytes(left.start, buf1, 0, left.end - left.start); String input = new String(buf1, com.google.common.base.Charsets.UTF_8); out.value = (org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC)).getMillis(); } }
public void eval() { if (left.start == left.end) { out.isSet = 0; return; } out.isSet = 1; // Get the input byte[] buf1 = new byte[left.end - left.start]; left.buffer.getBytes(left.start, buf1, 0, left.end - left.start); String input = new String(buf1, com.google.common.base.Charsets.UTF_8); out.value = (org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC)).getMillis(); } }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
for (final DateTimeFormatter formatter : dateFormats) { try { date = DateMidnight.parse(value, formatter); break; } catch (final Exception ex) { /* Do nothing, we'll get lots of these. */
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
/** * Parses a {@code DateMidnight} from the specified string. * <p> * This uses {@link ISODateTimeFormat#dateTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static DateMidnight parse(String str) { return parse(str, ISODateTimeFormat.dateTimeParser().withOffsetParsed()); }
public void eval() { // Get the input String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(left); try { out.value = org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); } catch (IllegalArgumentException e) { throw org.apache.drill.common.exceptions.UserException.functionError(e) .message("Error parsing date-time %s in %s function", input, "sql_to_date") .build(); } } }
public void eval() { if (left.isSet == 0 || left.start == left.end) { out.isSet = 0; return; } out.isSet = 1; // Get the input String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(left); try { out.value = org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); } catch (IllegalArgumentException e) { throw org.apache.drill.common.exceptions.UserException.functionError(e) .message("Error parsing date-time %s in %s function", input, "sql_to_nullabledate") .build(); } } }
public void eval() { if (left.start == left.end) { out.isSet = 0; return; } out.isSet = 1; // Get the input String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(left); try { out.value = org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); } catch (IllegalArgumentException e) { throw org.apache.drill.common.exceptions.UserException.functionError(e) .message("Error parsing date-time %s in %s function", input, "sql_to_nullabledate") .build(); } } }