MovieNFOReader { public static void movieDate(Movie movie, final String dateString) { String parseDate = StringUtils.normalizeSpace(dateString); if (StringTools.isNotValidString(parseDate)) { return; } Date parsedDate; try { parsedDate = DateTimeTools.parseStringToDate(parseDate); } catch (IllegalArgumentException ex) { LOG.warn("Failed parsing NFO file for movie: {}. Please fix or remove it.", movie.getBaseFilename()); LOG.warn("premiered or releasedate does not contain a valid date: {}", parseDate); LOG.warn(SystemTools.getStackTrace(ex)); if (OverrideTools.checkOverwriteReleaseDate(movie, NFO_PLUGIN_ID)) { movie.setReleaseDate(parseDate, NFO_PLUGIN_ID); } return; } if (parsedDate != null) { try { if (OverrideTools.checkOverwriteReleaseDate(movie, NFO_PLUGIN_ID)) { movie.setReleaseDate(DateTimeTools.convertDateToString(parsedDate, "yyyy-MM-dd"), NFO_PLUGIN_ID); } if (OverrideTools.checkOverwriteYear(movie, NFO_PLUGIN_ID)) { movie.setYear(DateTimeTools.convertDateToString(parsedDate, "yyyy"), NFO_PLUGIN_ID); } } catch (Exception ex) { LOG.warn("Failed formatting parsed date: {}", parsedDate); LOG.warn(SystemTools.getStackTrace(ex)); } } } private  MovieNFOReader(); static boolean readNfoFile(File nfoFile, Movie movie); static boolean readXmlNfo(String nfoText, Movie movie, String nfoFilename); static boolean readXmlNfo(File nfoFile, Movie movie); static boolean readTextNfo(String nfo, Movie movie); static void movieDate(Movie movie, final String dateString); static void parseRuntime(Element eCommon, Movie movie); static final String TYPE_MOVIE; static final String TYPE_TVSHOW; static final String TYPE_EPISODE; static final String NFO_PLUGIN_ID; }
@Test public void testMovieDate() { LOG.info("MovieDate"); String dateTest = "20/10/2005"; Movie m = new Movie(); MovieNFOReader.movieDate(m, dateTest); assertEquals("Wrong release year", "2005", m.getYear()); assertEquals("Wrong release date", "2005-10-20", m.getReleaseDate()); dateTest = "10/20/2005"; MovieNFOReader.movieDate(m, dateTest); assertEquals("Wrong release year", "2005", m.getYear()); assertEquals("Wrong release date", "2005-10-20", m.getReleaseDate()); }