empire Geschrieben 28. März 2002 Geschrieben 28. März 2002 Juten abend Mit welcher Klasse kann ich ein Datum in Millisek. ausgeben. Also sagen wir ich hätter gern das Datum 4.4.2002 um 12:00 uhr. und das nun in Millisek. die aktuelle Uhrzeit und Datum in Millisek. krieg ich ja mit System.currentTimeMillis raus. danke cu empire
Jaraz Geschrieben 28. März 2002 Geschrieben 28. März 2002 Hallo, du suchst.... GregorianCalendar public GregorianCalendar(int year, int month, int date, int hour, int minute) Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale. Parameters: year - the value used to set the YEAR time field in the calendar. month - the value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January. date - the value used to set the DATE time field in the calendar. hour - the value used to set the HOUR_OF_DAY time field in the calendar. minute - the value used to set the MINUTE time field in the calendar. Beispiel: import java.util.*; class { public static void main(String args[]) { GregorianCalendar c = new GregorianCalendar(int year, int month, int date, int hour, int minute); System.out.println(c.getTime().getTime()); } } Gruß Jaraz
Snowghost Geschrieben 29. März 2002 Geschrieben 29. März 2002 Alternativ kannst du auch java.util.Date verwenden java.util.Date d = new java.util.Date(); System.out.println("CurrentTime in millis="+d.getTime()); Die meisten Methoden aus java.util.Date sind jedoch deprecated - also für weitergehende Berechnungen wirklich den GregorianCalendar verwenden. Snowghost
Empfohlene Beiträge
Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren
Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können
Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!
Neues Benutzerkonto erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde Dich hier an.
Jetzt anmelden