*/
package org.opendaylight.restconf.nb.rfc8040.utils.validations;
-import java.text.ParseException;
+import java.time.format.DateTimeParseException;
import java.util.Date;
import java.util.Iterator;
+import java.util.Locale;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.restconf.common.validation.RestconfValidationUtils;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
/**
* Util class for validations.
* iterator
* @return {@link Date}
*/
- public static Date validateAndGetRevision(final Iterator<String> revisionDate) {
+ public static Revision validateAndGetRevision(final Iterator<String> revisionDate) {
RestconfValidationUtils.checkDocumentedError(revisionDate.hasNext(), ErrorType.PROTOCOL,
ErrorTag.INVALID_VALUE, "Revision date must be supplied.");
try {
- return SimpleDateFormatUtil.getRevisionFormat().parse(revisionDate.next());
- } catch (final ParseException e) {
+ return Revision.of(revisionDate.next());
+ } catch (final DateTimeParseException e) {
throw new RestconfDocumentedException("Supplied revision is not in expected date format YYYY-mm-dd", e);
}
}
);
RestconfValidationUtils.checkDocumentedError(
- !name.toUpperCase().startsWith("XML"),
+ !name.toUpperCase(Locale.ROOT).startsWith("XML"),
ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
"Identifier must NOT start with XML ignore case."
);