ParserUtils { public static String getYearMonthDayDirectory(Date date, ZoneId zoneId) { StringBuilder dirString = new StringBuilder(); LocalDate localDate = date.toInstant().atZone(zoneId).toLocalDate(); dirString.append(localDate.getYear()); dirString.append(Path.SEPARATOR).append(String.format("%02d", localDate.getMonthValue())); dirString.append(Path.SEPARATOR).append(String.format("%02d", localDate.getDayOfMonth())); return dirString.toString(); } private  ParserUtils(); @VisibleForTesting static boolean isValidHistFileName(String fileName, String jobIdRegex); static String getJhistFilePath(FileSystem fs, Path jobFolderPath); static long getCompletedTimeFromJhistFileName(String jhistFileName); static JobMetadata parseMetadata(FileSystem fs, YarnConfiguration yarnConf, Path jobFolderPath, String jobIdRegex); static List<JobConfig> parseConfig(FileSystem fs, Path jobFolderPath); static List<Event> parseEvents(FileSystem fs, Path jobFolderPath); static List<JobEvent> mapEventToJobEvent(List<Event> events); static List<JobLog> mapEventToJobLog(List<Event> events, JobLogMetaData jobLogMetaData); static String getYearMonthDayDirectory(Date date, ZoneId zoneId);  }
@Test public void testGetYearMonthDayDirectory() { Instant instant = Instant.ofEpochMilli(1559155036000L); Date date = Date.from(instant); ZoneId utc = ZoneId.of("UTC"); ZoneId gmt6 = ZoneId.of("GMT+6"); String expectedUTCDirectoryStr = "2019/05/29"; String expectedGMT6DirectoryStr = "2019/05/30"; String actualUTCDirectoryStr = ParserUtils.getYearMonthDayDirectory(date, utc); String actualGMT6DirectoryStr = ParserUtils.getYearMonthDayDirectory(date, gmt6); assertEquals(actualUTCDirectoryStr, expectedUTCDirectoryStr); assertEquals(actualGMT6DirectoryStr, expectedGMT6DirectoryStr); }