Hallo ich möchte einen Code schreiben der einen das genau alter in verschiedenen Zeitangaben sagt.
Mir wird allerdings diese Fehlermeldung ausgespuckt.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ChronoUnit cannot be resolved
ChronoUnit cannot be resolved
ChronoUnit cannot be resolved
Mir wird allerdings diese Fehlermeldung ausgespuckt.
Java:
import java.util.Scanner;
import java.time.LocalDate;
public class Alter
{
public static void main(String[] args)
{
Scanner zeta = new Scanner(System.in);
System.out.println("wir rechnen Ihr Alter in Monaten, Wochen. Tagen und Stunden aus."+"\n"+"gib Bitte dafür dein Geburtsdatum ein. Erst Jahr, dann Monat und dann Tag. YYYY,MM,DD");
int jahr, monat, tag;
jahr = zeta.nextInt();
monat = zeta.nextInt();
tag = zeta.nextInt();
LocalDate geburtstag = LocalDate.of(jahr,monat,tag);;
LocalDate heute = LocalDate.now();
int monate = ChronoUnit.MONTHS.between(geburtstag, heute);
int wochen = ChronoUnit.WEEKS.between(geburtstag, heute);
int tage = ChronoUnit.DAYS.between(geburtstag, heute);
int stunden = tage*24;
System.out.println("Sie sind genau " + monate + " MOnate alt.");
System.out.println("Sie sind genau " + wochen + " Wochen alt.");
System.out.println("Sie sind genau " + tage + " Tage alt.");
System.out.println("Sie sind ca. " + stunden + " Stunden alt.");
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ChronoUnit cannot be resolved
ChronoUnit cannot be resolved
ChronoUnit cannot be resolved