Eliminate custom SimpleDateFormat instances
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / repo / util / FilesystemSchemaSourceCache.java
index 6a4b83a5ebd5e9976a248e6a75bc60e3004a1812..e2d7d5d2b74fe85a95a4ed1704c79b66a0e9f05f 100644 (file)
@@ -27,7 +27,6 @@ import java.nio.file.StandardCopyOption;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.text.DateFormat;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -35,7 +34,9 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -184,7 +185,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
                  * String is comparable, pattern check tested format
                  * so comparing as ASCII string should be sufficient
                  */
-                DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+                DateFormat df = SimpleDateFormatUtil.getRevisionFormat();
                 try {
                     Date d = df.parse(revStr);
                     map.put(d, sorted);
@@ -290,7 +291,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
             if (matcher.matches()) {
                 final String moduleName = matcher.group("moduleName");
                 final String revision = matcher.group("revision");
-                return Optional.of(new SourceIdentifier(moduleName, Optional.fromNullable(revision)));
+                return Optional.of(RevisionSourceIdentifier.create(moduleName, Optional.fromNullable(revision)));
             }
             return Optional.absent();
         }