@Test public void testExtractYearOrNullWithInvalidInput() { assertNull(MetadataConverterUtils.extractYearOrNull("invalid", log)); assertNull(MetadataConverterUtils.extractYearOrNull("20200304", log)); assertNull(MetadataConverterUtils.extractYearOrNull("20-20-01", log)); assertNull(MetadataConverterUtils.extractYearOrNull("", log)); assertNull(MetadataConverterUtils.extractYearOrNull(null, log)); }
public static Year extractYearOrNull(String date, Logger log) { if (StringUtils.isNotBlank(date)) { return parseYearOrGetNull(date.indexOf('-') == 4 ? date.substring(0, date.indexOf('-')) : date, log); } else { return null; } }
MetadataConverterUtils { public static Year extractYearOrNull(String date, Logger log) { if (StringUtils.isNotBlank(date)) { return parseYearOrGetNull(date.indexOf('-') == 4 ? date.substring(0, date.indexOf('-')) : date, log); } else { return null; } } }
MetadataConverterUtils { public static Year extractYearOrNull(String date, Logger log) { if (StringUtils.isNotBlank(date)) { return parseYearOrGetNull(date.indexOf('-') == 4 ? date.substring(0, date.indexOf('-')) : date, log); } else { return null; } } private  MetadataConverterUtils(); }
MetadataConverterUtils { public static Year extractYearOrNull(String date, Logger log) { if (StringUtils.isNotBlank(date)) { return parseYearOrGetNull(date.indexOf('-') == 4 ? date.substring(0, date.indexOf('-')) : date, log); } else { return null; } } private  MetadataConverterUtils(); static List<String> extractValues(Collection<StructuredProperty> source, FieldApprover fieldApprover); static Year extractYearOrNull(String date, Logger log); }
MetadataConverterUtils { public static Year extractYearOrNull(String date, Logger log) { if (StringUtils.isNotBlank(date)) { return parseYearOrGetNull(date.indexOf('-') == 4 ? date.substring(0, date.indexOf('-')) : date, log); } else { return null; } } private  MetadataConverterUtils(); static List<String> extractValues(Collection<StructuredProperty> source, FieldApprover fieldApprover); static Year extractYearOrNull(String date, Logger log);  }