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