[ONOS-8031]Yang revision date are stored with default timezone

Change-Id: I14265b2e6c2f2b82f183f6317f79ec675dbc085c
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangImport.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangImport.java
index b3f0e2b..d4b3d1a 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangImport.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangImport.java
@@ -21,7 +21,7 @@
 import org.slf4j.Logger;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
 import java.util.Set;
 
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.findReferredNode;
@@ -96,7 +96,7 @@
      * the most recent "revision" statement in the imported module. organization
      * which defined the YANG module.
      */
-    private Date revision;
+    private LocalDate revision;
 
     /**
      * Reference to node which is imported.
@@ -151,7 +151,7 @@
      *
      * @return the revision of the imported module
      */
-    public Date getRevision() {
+    public LocalDate getRevision() {
         return revision;
     }
 
@@ -160,7 +160,7 @@
      *
      * @param rev set the revision of the imported module
      */
-    public void setRevision(Date rev) {
+    public void setRevision(LocalDate rev) {
         revision = rev;
     }
 
@@ -224,7 +224,7 @@
      */
     public void addReferenceToImport(Set<YangNode> yangNodeSet) throws DataModelException {
         String importedModuleName = getModuleName();
-        Date importedModuleRevision = getRevision();
+        LocalDate importedModuleRevision = getRevision();
         YangNode moduleNode = null;
         /*
          * Find the imported module node for a given module name with a
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInclude.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInclude.java
index 873ec6e..2d520d3 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInclude.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInclude.java
@@ -20,7 +20,7 @@
 import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
 import java.util.Set;
 
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.findReferredNode;
@@ -57,7 +57,7 @@
      * The include's "revision-date" statement is used to specify the exact
      * version of the submodule to import.
      */
-    private Date revision;
+    private LocalDate revision;
 
     /**
      * Reference to node which is included.
@@ -93,7 +93,7 @@
      *
      * @return the revision
      */
-    public Date getRevision() {
+    public LocalDate getRevision() {
         return revision;
     }
 
@@ -102,7 +102,7 @@
      *
      * @param revision the revision to set
      */
-    public void setRevision(Date revision) {
+    public void setRevision(LocalDate revision) {
         this.revision = revision;
     }
 
@@ -157,7 +157,7 @@
      */
     public YangSubModule addReferenceToInclude(Set<YangNode> yangNodeSet) throws DataModelException {
         String includedSubModuleName = getSubModuleName();
-        Date includedSubModuleRevision = getRevision();
+        LocalDate includedSubModuleRevision = getRevision();
         YangNode subModuleNode = null;
 
         /*
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRevision.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRevision.java
index 6d4a52b..fdafdb4 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRevision.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRevision.java
@@ -20,7 +20,7 @@
 import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
 
 /*
  *  Reference:RFC 6020.
@@ -55,7 +55,7 @@
     /**
      * Revision date. Date string in the format "YYYY-MM-DD"
      */
-    private Date revDate;
+    private LocalDate revDate;
 
     /**
      * Description of revision.
@@ -78,7 +78,7 @@
      *
      * @return the revision date
      */
-    public Date getRevDate() {
+    public LocalDate getRevDate() {
         return revDate;
     }
 
@@ -87,7 +87,7 @@
      *
      * @param revDate the revision date to set
      */
-    public void setRevDate(Date revDate) {
+    public void setRevDate(LocalDate revDate) {
         this.revDate = revDate;
     }
 
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
index 9a9cde1..b3b60a4 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
@@ -76,7 +76,6 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -1476,8 +1475,7 @@
     public static String getDateInStringFormat(YangNode schemaNode) {
         if (schemaNode != null) {
             if (schemaNode.getRevision() != null) {
-                return new SimpleDateFormat(DATE_FORMAT)
-                        .format(schemaNode.getRevision().getRevDate());
+                return schemaNode.getRevision().getRevDate().toString();
             }
         }
         return null;
diff --git a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListener.java b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListener.java
index e51c33b..b299b66 100644
--- a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListener.java
+++ b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListener.java
@@ -22,7 +22,7 @@
 import org.onosproject.yang.compiler.parser.exceptions.ParserException;
 import org.onosproject.yang.compiler.parser.impl.TreeWalkListener;
 
-import java.util.Date;
+import java.time.LocalDate;
 
 import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.REVISION_DATE_DATA;
 import static org.onosproject.yang.compiler.parser.antlrgencode.GeneratedYangParser.RevisionDateStatementContext;
@@ -88,7 +88,7 @@
         checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATE_DATA, ctx.dateArgumentString().getText(),
                 ENTRY);
 
-        Date date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
+        LocalDate date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
 
         // Obtain the node of the stack.
         Parsable tmpNode = listener.getParsedDataStack().peek();
diff --git a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListener.java b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListener.java
index 5868328..f3ba93d 100644
--- a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListener.java
+++ b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListener.java
@@ -23,7 +23,7 @@
 import org.onosproject.yang.compiler.parser.exceptions.ParserException;
 import org.onosproject.yang.compiler.parser.impl.TreeWalkListener;
 
-import java.util.Date;
+import java.time.LocalDate;
 
 import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.REVISION_DATA;
 import static org.onosproject.yang.compiler.parser.antlrgencode.GeneratedYangParser.RevisionStatementContext;
@@ -89,7 +89,7 @@
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, ctx.dateArgumentString().getText(), ENTRY);
 
-        Date date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
+        LocalDate date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
 
         YangRevision revisionNode = new YangRevision();
         revisionNode.setRevDate(date);
@@ -123,8 +123,8 @@
                 case MODULE_DATA: {
                     YangModule module = (YangModule) tmpNode;
                     if (module.getRevision() != null) {
-                        Date curRevisionDate = module.getRevision().getRevDate();
-                        if (curRevisionDate.before(((YangRevision) tmpRevisionNode).getRevDate())) {
+                        LocalDate curRevisionDate = module.getRevision().getRevDate();
+                        if (curRevisionDate.isBefore(((YangRevision) tmpRevisionNode).getRevDate())) {
                             module.setRevision((YangRevision) tmpRevisionNode);
                         }
                     } else {
@@ -135,8 +135,8 @@
                 case SUB_MODULE_DATA: {
                     YangSubModule subModule = (YangSubModule) tmpNode;
                     if (subModule.getRevision() != null) {
-                        Date curRevisionDate = subModule.getRevision().getRevDate();
-                        if (curRevisionDate.before(((YangRevision) tmpRevisionNode).getRevDate())) {
+                        LocalDate curRevisionDate = subModule.getRevision().getRevDate();
+                        if (curRevisionDate.isBefore(((YangRevision) tmpRevisionNode).getRevDate())) {
                             subModule.setRevision((YangRevision) tmpRevisionNode);
                         }
                     } else {
diff --git a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/parserutils/ListenerUtil.java b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/parserutils/ListenerUtil.java
index 538e863..7d8c5a1 100644
--- a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/parserutils/ListenerUtil.java
+++ b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/parserutils/ListenerUtil.java
@@ -39,10 +39,8 @@
 import org.onosproject.yang.compiler.translator.tojava.javamodel.YangJavaAugmentTranslator;
 import org.slf4j.Logger;
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -70,6 +68,7 @@
 import static org.onosproject.yang.compiler.utils.UtilConstants.CURRENT;
 import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
 import static org.onosproject.yang.compiler.utils.UtilConstants.FALSE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
 import static org.onosproject.yang.compiler.utils.UtilConstants.IN;
 import static org.onosproject.yang.compiler.utils.UtilConstants.INVALID_TREE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.ONE;
@@ -103,6 +102,8 @@
             Pattern.compile("\\[(.*?)\\]");
     private static final String XML = "xml";
     private static final int IDENTIFIER_LENGTH = 64;
+    private static final int VALUE_CHECK = 10;
+    private static final int ZERO = 0;
     private static final String DATE_FORMAT = "yyyy-MM-dd";
     private static final String REGEX_EQUAL = "[=]";
     private static final String REGEX_OPEN_BRACE = "[(]";
@@ -173,30 +174,6 @@
     }
 
     /**
-     * Validates the revision date.
-     *
-     * @param dateToValidate input revision date
-     * @return validation result, true for success, false for failure
-     */
-    public static boolean isDateValid(String dateToValidate) {
-        if (dateToValidate == null || !dateToValidate.matches(DATE_PATTERN)) {
-            return false;
-        }
-
-        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-        sdf.setLenient(false);
-
-        try {
-            //if not valid, it will throw ParseException
-            sdf.parse(dateToValidate);
-        } catch (ParseException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
      * Validates YANG version.
      *
      * @param ctx version context object of the grammar rule
@@ -311,27 +288,6 @@
     }
 
     /**
-     * Returns current date and makes it in usable format for revision.
-     *
-     * @return usable current date format for revision
-     */
-    public static Date getCurrentDateForRevision() {
-
-        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
-
-        Date date = new Date();
-        String dateInString = dateFormat.format(date);
-        try {
-            //if not valid, it will throw ParseException
-            Date now = dateFormat.parse(dateInString);
-            return date;
-        } catch (ParseException e) {
-            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
-            throw parserException;
-        }
-    }
-
-    /**
      * Checks and return valid node identifier.
      *
      * @param nodeIdentifierString string from yang file
@@ -630,7 +586,7 @@
      * @param ctx          yang construct's context to get the line number and character position
      * @return date format for revision
      */
-    public static Date getValidDateFromString(String dateInString, ParserRuleContext ctx) {
+    public static LocalDate getValidDateFromString(String dateInString, ParserRuleContext ctx) {
         String dateArgument = removeQuotesAndHandleConcat(dateInString);
         if (!dateArgument.matches(DATE_PATTERN)) {
             ParserException parserException = new ParserException("YANG file error: Input date is not correct");
@@ -639,18 +595,20 @@
             throw parserException;
         }
 
-        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-        sdf.setLenient(false);
+        String[] revisionArr = dateArgument.toString().split(HYPHEN);
 
-        try {
-            //if not valid, it will throw ParseException
-            return sdf.parse(dateArgument);
-        } catch (ParseException e) {
-            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
-            parserException.setLine(ctx.getStart().getLine());
-            parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
-            throw parserException;
+        StringBuilder rev = new StringBuilder(revisionArr[0]);
+        for (int i = 1; i < revisionArr.length; i++) {
+            rev.append(HYPHEN);
+            Integer val = Integer.parseInt(revisionArr[i]);
+            if (val < VALUE_CHECK) {
+                rev.append(ZERO);
+            }
+            rev.append(val);
         }
+
+        //if not valid, it will throw ParseException
+        return LocalDate.parse(rev);
     }
 
     /**
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ImportListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ImportListenerTest.java
index 31ba584..b47c957 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ImportListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ImportListenerTest.java
@@ -24,7 +24,7 @@
 
 import java.io.IOException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -35,8 +35,6 @@
 public class ImportListenerTest {
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
-    private static final String DATE_FORMAT = "yyyy-MM-dd";
-    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
 
     /**
      * Checks if mandatory parameter prefix is present in import.
@@ -74,7 +72,7 @@
         YangNode node = manager.getDataModel("src/test/resources/ImportValidEntry.yang");
 
         // Checks for the revision value in data model tree.
-        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(simpleDateFormat.parse("2015-02-03")));
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(LocalDate.parse("2015-02-03")));
         // Checks for the prefix id in data model tree.
         assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
         // Checks for the module name in data model tree.
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/IncludeListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/IncludeListenerTest.java
index db549de..c25d02f 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/IncludeListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/IncludeListenerTest.java
@@ -24,7 +24,7 @@
 
 import java.io.IOException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -35,8 +35,6 @@
 public class IncludeListenerTest {
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
-    private static final String DATE_FORMAT = "yyyy-MM-dd";
-    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
 
     /**
      * Checks if include listener with ; is valid and updates the data
@@ -75,7 +73,7 @@
 
         // Checks for the sub module name in data model tree.
         assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
     }
 
     /**
@@ -88,9 +86,9 @@
 
         // Checks for the sub module name in data model tree.
         assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
         assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
-        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(simpleDateFormat.parse("2014-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(LocalDate.parse("2014-02-03")));
     }
 
     /**
@@ -103,9 +101,9 @@
 
         // Checks for the sub module name in data model tree.
         assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
         assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
-        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(simpleDateFormat.parse("2014-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(LocalDate.parse("2014-02-03")));
     }
 
     /**
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListenerTest.java
index 7f088e8..27ffe05 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionDateListenerTest.java
@@ -24,7 +24,8 @@
 
 import java.io.IOException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeParseException;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -35,8 +36,6 @@
 public class RevisionDateListenerTest {
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
-    private static final String DATE_FORMAT = "yyyy-MM-dd";
-    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
 
     /**
      * Checks if revision date syntax is correct in include.
@@ -64,9 +63,9 @@
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtInclude.yang");
         // Checks for the version value in data model tree.
-        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(simpleDateFormat.parse("2015-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(simpleDateFormat.parse("2014-02-03")));
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(LocalDate.parse("2015-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(LocalDate.parse("2014-02-03")));
     }
 
     /**
@@ -77,9 +76,9 @@
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtImport.yang");
         // Checks for the version value in data model tree.
-        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(simpleDateFormat.parse("2015-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(simpleDateFormat.parse("2014-02-03")));
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(LocalDate.parse("2015-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(LocalDate.parse("2014-02-03")));
     }
 
     /**
@@ -94,7 +93,7 @@
     /**
      * Checks if revision date is correct.
      */
-    @Test(expected = ParserException.class)
+    @Test(expected = DateTimeParseException.class)
     public void processRevisionDateInvalid() throws IOException, ParserException {
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalid.yang");
@@ -109,8 +108,8 @@
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateValidEntry.yang");
 
         // Checks for the version value in data model tree.
-        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(simpleDateFormat.parse("2015-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(simpleDateFormat.parse("2016-02-03")));
-        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(simpleDateFormat.parse("2014-02-03")));
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is(LocalDate.parse("2015-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is(LocalDate.parse("2016-02-03")));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is(LocalDate.parse("2014-02-03")));
     }
 }
\ No newline at end of file
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListenerTest.java
index 8c7a816..0ce6886 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/RevisionListenerTest.java
@@ -24,7 +24,7 @@
 
 import java.io.IOException;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -35,8 +35,6 @@
 public class RevisionListenerTest {
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
-    private static final String DATE_FORMAT = "yyyy-MM-dd";
-    private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
 
     /**
      * Checks if revision doesn't have optional parameters "revision and
@@ -47,7 +45,7 @@
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionNoOptionalParameter.yang");
         // Checks for the version value in data model tree.
-        assertThat(((YangModule) node).getRevision().getRevDate(), is(simpleDateFormat.parse("2016-02-03")));
+        assertThat(((YangModule) node).getRevision().getRevDate(), is(LocalDate.parse("2016-02-03")));
     }
 
     /**
@@ -85,6 +83,33 @@
     public void processWithMultipleRevision() throws IOException, ParserException, ParseException {
 
         YangNode node = manager.getDataModel("src/test/resources/MultipleRevision.yang");
-        assertThat((node).getRevision().getRevDate(), is(simpleDateFormat.parse("2013-07-15")));
+        assertThat((node).getRevision().getRevDate(), is(LocalDate.parse("2013-07-15")));
+    }
+
+    /**
+     * Checks revision month of date in single digit format.
+     */
+    @Test
+    public void processRevisionDateWithSingleDigitMonth() throws IOException, ParserException, ParseException {
+        YangNode node = manager.getDataModel("src/test/resources/RevisionMonthSingleDigit.yang");
+        assertThat((node).getRevision().getRevDate(), is(LocalDate.parse("2013-07-15")));
+    }
+
+    /**
+     * Checks revision day in single digit format.
+     */
+    @Test
+    public void processRevisionDateWithSingleDigitDay() throws IOException, ParserException, ParseException {
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDaySingleDigit.yang");
+        assertThat((node).getRevision().getRevDate(), is(LocalDate.parse("2013-10-07")));
+    }
+
+    /**
+     * Checks revision day and month in single digit format.
+     */
+    @Test
+    public void processRevisionDateWithSingleDigitDayMonth() throws IOException, ParserException, ParseException {
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDayMonthSingleDigit.yang");
+        assertThat((node).getRevision().getRevDate(), is(LocalDate.parse("2013-07-07")));
     }
 }
\ No newline at end of file
diff --git a/compiler/base/parser/src/test/resources/RevisionDayMonthSingleDigit.yang b/compiler/base/parser/src/test/resources/RevisionDayMonthSingleDigit.yang
new file mode 100755
index 0000000..96686cb
--- /dev/null
+++ b/compiler/base/parser/src/test/resources/RevisionDayMonthSingleDigit.yang
@@ -0,0 +1,17 @@
+module Test {
+    yang-version 1;
+    namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+    prefix test;
+
+     revision 2013-7-7 {
+       description
+        "This revision adds the following new data types:
+         - yang-identifier
+         - hex-string
+         - uuid
+         - dotted-quad";
+       reference
+        "RFC 6991: Common YANG Data Types";
+     }
+
+}
diff --git a/compiler/base/parser/src/test/resources/RevisionDaySingleDigit.yang b/compiler/base/parser/src/test/resources/RevisionDaySingleDigit.yang
new file mode 100755
index 0000000..0c60001
--- /dev/null
+++ b/compiler/base/parser/src/test/resources/RevisionDaySingleDigit.yang
@@ -0,0 +1,17 @@
+module Test {
+    yang-version 1;
+    namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+    prefix test;
+
+     revision 2013-10-7 {
+       description
+        "This revision adds the following new data types:
+         - yang-identifier
+         - hex-string
+         - uuid
+         - dotted-quad";
+       reference
+        "RFC 6991: Common YANG Data Types";
+     }
+
+}
diff --git a/compiler/base/parser/src/test/resources/RevisionMonthSingleDigit.yang b/compiler/base/parser/src/test/resources/RevisionMonthSingleDigit.yang
new file mode 100755
index 0000000..6e75f73
--- /dev/null
+++ b/compiler/base/parser/src/test/resources/RevisionMonthSingleDigit.yang
@@ -0,0 +1,17 @@
+module Test {
+    yang-version 1;
+    namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+    prefix test;
+
+     revision 2013-7-15 {
+       description
+        "This revision adds the following new data types:
+         - yang-identifier
+         - hex-string
+         - uuid
+         - dotted-quad";
+       reference
+        "RFC 6991: Common YANG Data Types";
+     }
+
+}
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
index 9e14b5b..b9f7d46 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -25,10 +25,9 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
 
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
@@ -111,10 +110,8 @@
      * @param date YANG module revision
      * @return revision string
      */
-    private static String getYangRevisionStr(Date date) {
-        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
-        String dateInString = sdf.format(date);
-        String[] revisionArr = dateInString.split(HYPHEN);
+    private static String getYangRevisionStr(LocalDate date) {
+        String[] revisionArr = date.toString().split(HYPHEN);
 
         StringBuilder rev = new StringBuilder(REVISION_PREFIX)
                 .append(revisionArr[INDEX_ZERO]);
diff --git a/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntaxTest.java
index 6ef2d3a..0d37798 100644
--- a/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntaxTest.java
+++ b/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -31,7 +31,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.LocalDate;
 
 import static org.apache.commons.io.FileUtils.deleteDirectory;
 import static org.hamcrest.core.Is.is;
@@ -52,7 +52,7 @@
 
     private static final String PARENT_PACKAGE = "test5/test6/test7";
     private static final String CHILD_PACKAGE = "test1-test2-test3";
-    private static final String DATE1 = "2000-1-5";
+    private static final String DATE1 = "2000-01-05";
     private static final String DATE2 = "1992-01-25";
     private static final String PARENT_WITH_PERIOD = "test5.test6.test7";
     private static final String CHILD_WITH_PERIOD = "test1test2test3";
@@ -174,7 +174,6 @@
     @Test
     public void getRootPackageWithRevTest()
             throws ParseException {
-        Date date = simpleDateFormat.parse(DATE2);
         String rootPkgWithRev = getRootPackage("1", CHILD_PACKAGE,
                                                getYangRevision(DATE2), null);
         assertThat(rootPkgWithRev.equals(
@@ -306,11 +305,7 @@
 
     private YangRevision getYangRevision(String date) {
         YangRevision revision = new YangRevision();
-        try {
-            revision.setRevDate(simpleDateFormat.parse(date));
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
+        revision.setRevDate(LocalDate.parse(date));
         return revision;
     }
 }