// Opgave 17 // Morten Proschowsky import java.text.DecimalFormat; public class Dato { // Navne på måneder final static String[] danishMonths = {"januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"}; // Instanser af DecimalFormat til formatering af ISO dato final static DecimalFormat twoDig = new DecimalFormat("00"); final static DecimalFormat fourDig = new DecimalFormat("0000"); // Instans data private int year, month, day; // Konstruktor public Dato(int year, int month, int day) { this.year = year; this.month = month; this.day = day; } public String iso() { return fourDig.format(year) +"-"+ twoDig.format(month) +"-"+ twoDig.format(day); } public String danish() { return day +"/"+ month +" "+ year; } public String danishText() { return day +". "+ danishMonths[month-1] +" "+ year; } }