2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.yangtools.yang.common;
11 import java.text.ParseException;
12 import java.text.SimpleDateFormat;
13 import java.util.Date;
15 public final class SimpleDateFormatUtil {
17 private static final String REVISION_SIMPLE_DATE = "yyyy-MM-dd";
18 private static final String DEFAULT_DATE = "1970-01-01";
20 public static Date DEFAULT_DATE_REV;
21 public static Date DEFAULT_DATE_IMP;
24 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(REVISION_SIMPLE_DATE);
27 DEFAULT_DATE_REV = simpleDateFormat.parse(DEFAULT_DATE);
28 DEFAULT_DATE_IMP = simpleDateFormat.parse(DEFAULT_DATE);
29 } catch (ParseException e) {
30 throw new ExceptionInInitializerError(e);
34 private SimpleDateFormatUtil() {
35 throw new UnsupportedOperationException("Utility class should not be instantiated");
38 private static final ThreadLocal<SimpleDateFormat> REVISION_FORMAT = new ThreadLocal<SimpleDateFormat>() {
41 protected SimpleDateFormat initialValue() {
42 return new SimpleDateFormat(REVISION_SIMPLE_DATE);
46 public void set(SimpleDateFormat value) {
47 throw new UnsupportedOperationException();
52 public static SimpleDateFormat getRevisionFormat() {
53 return REVISION_FORMAT.get();