// ------------------------- Aufgabe 1 ---------------------------- \\
//aktuelles Datum
Date heute = new Date();
System.out.println("heute = " + heute);
DateFormat localFormat = DateFormat.getDateInstance(DateFormat.LONG) ;
String local = localFormat.format(heute) ;
System.out.println(local); // tt monat.jjjj
long heuteMillis = heute.getTime() ;
long milliDay = 24L*60*60*1000; // 24L erzwingt auswertung in long !
Date morgen = new Date(heuteMillis + milliDay) ;
System.out.println("morgen = " + morgen);
Date gestern = new Date(heuteMillis - milliDay) ;
System.out.println("gestern = " + gestern);
// ------------------------- Aufgabe 2 ---------------------------- \\
//January 1, 1970, 00:00:00 GMT
Date epoque = new Date(0);
System.out.println("epoque = " + epoque);
DateFormat localFormat = DateFormat.getDateInstance(DateFormat.LONG) ;
String local = localFormat.format(epoque) ;
System.out.println(local); // tt monat.jjjj
long milliYear = 365L*24*60*60*1000 ;
Date before = new Date(-milliYear) ;
Date after = new Date(milliYear) ;
System.out.println("before = " + before);
System.out.println("after = " + after);
// ------------------------- Aufgabe 3 ---------------------------- \\
//January 1, 1970, 00:00:00 GMT
Date epoque = new Date(0);
System.out.println("epoque = " + epoque);
Date maxIntDate = new Date(Integer.MAX_VALUE) ;
System.out.println("maxIntDate = "+ maxIntDate); //
//long milliYear = 365L*24*60*60*1000 ;
//Date year5050 = new Date( new Date(0).getTime() + milliYear*3083) ;
//System.out.println("year5050 = "+ year5050); //
Date maxLongDate = new Date(Long.MAX_VALUE) ;
System.out.println("maxLongDate = "+ maxLongDate); //
Date minIntDate = new Date(Integer.MIN_VALUE) ;
System.out.println("minIntDate = " + minIntDate); //
Date minLongDate = new Date(Long.MIN_VALUE) ;
System.out.println("minLongDate = " + minLongDate); //
// ------------------------- Aufgabe 4 ---------------------------- \\
Calendar franzRev1 = Calendar.getInstance();
franzRev1.set(1789, 6, 14); // monatszählung : januar=0 !
Date revolution1 = franzRev1.getTime();
System.out.println("revolution1 = "+revolution1);
long millis = revolution1.getTime();
System.out.println("millis = "+ millis);
System.out.println("-------------------------------------");
Calendar franzRev2 = Calendar.getInstance();
franzRev2.set(1789, 6, 14, 0, 0, 0); // monatszählung : januar=0 !
Date revolution2 = franzRev2.getTime();
System.out.println("revolution2 = "+revolution2);
long millis2 = revolution2.getTime();
System.out.println("millis2 = "+ millis2);
// ------------------------- Aufgabe 5 ---------------------------- \\
GregorianCalendar gregCal = new GregorianCalendar() ; // 01.01.1200
boolean year2000 = gregCal.isLeapYear(2000) ;
System.out.println("2000 war ein Schaltjahr : "+ year2000);
// ------------------------- Aufgabe 6 ---------------------------- \\
GregorianCalendar gregCal = new GregorianCalendar() ; // 01.01.1200
Date change = gregCal.getGregorianChange();
System.out.println("Kalenderumstellung : "+ change);
boolean year1200 = gregCal.isLeapYear(2000) ;
System.out.println("1200 war ein Schaltjahr : "+ year1200);
// ------------------------- Aufgabe 7 ---------------------------- \\
GregorianCalendar thursday =
new GregorianCalendar(1582, 9, 4, 12, 0, 0) ; // 4. Oktober 1582
System.out.println("thursday = "+ thursday.getTime() );
thursday.add(Calendar.DATE, 1) ;
System.out.println("friday = "+ thursday.getTime() );