001/* Copyright (C) 2014 konik.io
002 *
003 * This file is part of the Konik library.
004 *
005 * The Konik library is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * The Konik library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with the Konik library. If not, see <http://www.gnu.org/licenses/>.
017 */
018package io.konik.zugferd.unqualified;
019
020import java.text.SimpleDateFormat;
021import java.util.Date;
022
023/**
024 * The ZUGFeRD Date with year and month.
025 */
026public class ZfDateMonth extends ZfDate {
027   private static final long serialVersionUID = 2756814691171025048L;
028
029   /** The format code for year and month. */
030   public static final String CODE = "610";
031   private static final String DATE_PATTERN = "yyyyMM";
032   private static final ThreadLocal<SimpleDateFormat> formatter = new ThreadLocal<SimpleDateFormat>() {
033      @Override
034      protected SimpleDateFormat initialValue() {
035         return new SimpleDateFormat(DATE_PATTERN);
036      }
037   };
038
039   /**
040    * Instantiates a new zf date with current year and month
041    */
042   public ZfDateMonth() {
043      super();
044   }
045
046   /**
047    * Instantiates a new zf date with current year and month
048    *
049    * @param date the date
050    */
051   public ZfDateMonth(Date date) {
052      super(date);
053   }
054
055   /**
056    * Instantiates a new zf date month.
057    *
058    * @param date the date
059    */
060   public ZfDateMonth(long date) {
061      super(date);
062   }
063
064   /**
065    * Instantiates a new zf date month.
066    *
067    * @param formattedDate the formatted date
068    */
069   public ZfDateMonth(String formattedDate) {
070      super(formattedDate);
071   }
072
073   /**
074    * Gets the format code.
075    *
076    * @return the format code
077    */
078   @Override
079   public String getFormatCode() {
080      return CODE;
081   }
082
083   @Override
084   SimpleDateFormat getFormatter() {
085      return formatter.get();
086   }
087
088}