All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mustangproject.ZUGFeRD.ZUGFeRDDateFormat Maven / Gradle / Ivy

Go to download

FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT Cross Industry Invoice based formats Factur-X/ZUGFeRD, XRechnung and Order-X in your invoice PDFs.

There is a newer version: 2.15.2
Show newest version
package org.mustangproject.ZUGFeRD;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.mustangproject.ZUGFeRD.model.DateTimeTypeConstants;

public enum ZUGFeRDDateFormat {

	MONTH_OF_YEAR(DateTimeTypeConstants.MONTH, new SimpleDateFormat("yyyyMM")),
	WEEK_OF_YEAR(DateTimeTypeConstants.WEEK, new SimpleDateFormat("yyyyww")),
	DATE(DateTimeTypeConstants.DATE, new SimpleDateFormat("yyyyMMdd"));

	private String dateTimeType;
	private SimpleDateFormat formatter;
	private static final String QDT_FORMAT = "%s";
	private static final String UDT_FORMAT = "%s";

	private ZUGFeRDDateFormat(String dateTimeType, SimpleDateFormat formatter) {
		this.dateTimeType = dateTimeType;
		this.formatter = formatter;
	}

	public String getDateTimeType() {
		return dateTimeType;
	}

	public SimpleDateFormat getFormatter() {
		return formatter;
	}
	
	public String simpleFormat(Date date){
    return getFormatter().format(date);
  }
	public String qdtFormat(Date date){
    return String.format(QDT_FORMAT, getDateTimeType(), getFormatter().format(date));
  }
	public String udtFormat(Date date){
    return String.format(UDT_FORMAT, getDateTimeType(), getFormatter().format(date));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy