/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
private boolean isDatePatternHourly(String datePattern) { DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern); LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0); String refDateTimeString = refDateTime.toString(formatter); LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0); String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter); return !refDateTimeString.equals(refDateTimeStringAtStartOfDay); }
@Override protected List<FileStatus> getFilesAtPath(FileSystem fs, Path path, PathFilter fileFilter) throws IOException { DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern); LocalDateTime endDate = currentTime; LocalDateTime startDate = endDate.minus(this.lookbackPeriod); DateRangeIterator dateRangeIterator = new DateRangeIterator(startDate, endDate, isPatternHourly); List<FileStatus> fileStatuses = Lists.newArrayList(); while (dateRangeIterator.hasNext()) { Path pathWithDateTime = new Path(path, dateRangeIterator.next().toString(formatter)); fileStatuses.addAll(super.getFilesAtPath(fs, pathWithDateTime, fileFilter)); } return fileStatuses; } }
@Test public void testIterator() { LocalDateTime endDate = new LocalDateTime(2017, 1, 1, 0, 0, 0); LocalDateTime startDate = endDate.minusHours(2); String datePattern = "HH/yyyy/MM/dd"; DateTimeFormatter format = DateTimeFormat.forPattern(datePattern); TimeAwareRecursiveCopyableDataset.DateRangeIterator dateRangeIterator = new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, true); LocalDateTime dateTime = dateRangeIterator.next(); Assert.assertEquals(dateTime.toString(format), "22/2016/12/31"); dateTime = dateRangeIterator.next(); Assert.assertEquals(dateTime.toString(format), "23/2016/12/31"); dateTime = dateRangeIterator.next(); Assert.assertEquals(dateTime.toString(format), "00/2017/01/01"); Assert.assertEquals(dateRangeIterator.hasNext(), false); datePattern = "yyyy/MM/dd"; format = DateTimeFormat.forPattern(datePattern); startDate = endDate.minusDays(1); dateRangeIterator = new TimeAwareRecursiveCopyableDataset.DateRangeIterator(startDate, endDate, false); dateTime = dateRangeIterator.next(); Assert.assertEquals(dateTime.toString(format), "2016/12/31"); dateTime = dateRangeIterator.next(); Assert.assertEquals(dateTime.toString(format), "2017/01/01"); Assert.assertEquals(dateRangeIterator.hasNext(), false); } }
String startDate = endDate.minusHours(i).toString(formatter); Path subDirPath = new Path(baseDir1, new Path(startDate)); fs.mkdirs(subDirPath); String startDate = endDate.minusHours(i).toString(formatter); Path subDirPath = new Path(baseDir1, new Path(startDate)); Path filePath = new Path(subDirPath, i + ".avro"); String startDate = endDate.minusDays(i).toString(formatter); Path subDirPath = new Path(baseDir2, new Path(startDate)); fs.mkdirs(subDirPath);
@Override protected String toJsonISO8601(LocalDateTime value) { return value.toString(); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @param locale Locale to use, null means default * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern, Locale locale) throws IllegalArgumentException { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).withLocale(locale).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
/** * Output the date using the specified format pattern. * * @param pattern the pattern specification, null means use <code>toString</code> * @see org.joda.time.format.DateTimeFormat */ public String toString(String pattern) { if (pattern == null) { return toString(); } return DateTimeFormat.forPattern(pattern).print(this); }
public static String formatDateTimeForXml(LocalDateTime localDateTime) { if (localDateTime == null) return null; if (localDateTime.getMillisOfSecond() != 0) return localDateTime.toString(DATETIME_WITH_MILLIS_XML); else if (localDateTime.getSecondOfMinute() != 0) return localDateTime.toString(DATETIME_WITH_SECONDS_XML); else return localDateTime.toString(DATETIME_XML); }
public static String formatDateTimeForXml(LocalDateTime localDateTime) { if (localDateTime == null) return null; if (localDateTime.getMillisOfSecond() != 0) return localDateTime.toString(DATETIME_WITH_MILLIS_XML); else if (localDateTime.getSecondOfMinute() != 0) return localDateTime.toString(DATETIME_WITH_SECONDS_XML); else return localDateTime.toString(DATETIME_XML); }
private boolean isDatePatternHourly(String datePattern) { DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern); LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0); String refDateTimeString = refDateTime.toString(formatter); LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0); String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter); return !refDateTimeString.equals(refDateTimeStringAtStartOfDay); }
@Override public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { pos.setBeginIndex(0); pos.setEndIndex(0); toAppendTo.append(((LocalDateTime) obj).toString(dateTimeFormatter)); return toAppendTo; }
@Test public void testToChar() throws Exception { String expectedResults[] = {(new LocalDate(2008, 2, 23)).toString("yyyy-MMM-dd"), (new LocalTime(12, 20, 30)).toString("HH mm ss"), (new LocalDateTime(2008, 2, 23, 12, 0, 0)).toString("yyyy MMM dd HH:mm:ss")}; testCommon(expectedResults, "/functions/date/to_char.json", "/test_simple_date.json"); }