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, month and day. Time 025 */ 026public class ZfDateDay extends ZfDate { 027 028 private static final long serialVersionUID = -467516960528526434L; 029 030 /** The code format. */ 031 public static final String CODE = "102"; 032 033 /** The date pattern. */ 034 public static final String DATE_PATTERN = "yyyyMMdd"; 035 private static final ThreadLocal<SimpleDateFormat> formatter = new ThreadLocal<SimpleDateFormat>() { 036 @Override 037 protected SimpleDateFormat initialValue() { 038 return new SimpleDateFormat(DATE_PATTERN); 039 } 040 }; 041 042 /** 043 * Instantiates a new zf date day. 044 */ 045 public ZfDateDay() { 046 super(); 047 } 048 049 /** 050 * Instantiates a new zf date day. 051 * 052 * @param date the date 053 */ 054 public ZfDateDay(Date date) { 055 super(date); 056 } 057 058 /** 059 * Instantiates a new zf date day. 060 * 061 * @param date the date 062 */ 063 public ZfDateDay(long date) { 064 super(date); 065 } 066 067 /** 068 * Instantiates a new zf date day. 069 * 070 * @param formattedDate the formatted date 071 */ 072 public ZfDateDay(String formattedDate) { 073 super(formattedDate); 074 } 075 076 /** 077 * Gets the format code. 078 * 079 * @return the format code 080 */ 081 @Override 082 public String getFormatCode() { 083 return CODE; 084 } 085 086 /** 087 * Gets the formatter. 088 * 089 * @return the formatter 090 */ 091 @Override 092 public SimpleDateFormat getFormatter() { 093 return formatter.get(); 094 } 095}