Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Leutz!

Ich will mit der Methode GregorianCalendar Tag/Monat/Jahr anzeigen lassen. Klappt auch so einigermaßen, nur das ich beim Monat den 6 statt den 7 angezeigt bekomme. Jemand 'ne Idee woran das liegen könnte?

Weil es so ist. :D

Formatierte Datumsausgaben kannst du mit der Klasse DateFormat ausgeben oder du rechnest von Hand einfach 1 dazu.

Gruß Jaraz

Original geschrieben von Der Kleine

Kann es sein, daß der Monat mal bei 0 (also 0 - 11) angefangen zu zählen wird, mal bei 1 (also 1 - 12)?

:confused: Hm, ich weiß zwar nicht genau, was du damit meinst, aber der Monat wird beim GregorianCalendar mit Januar = 0 angegeben.

MONTH

public static final int MONTH

Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year is JANUARY which is 0; the last depends on the number of months in a year.

Bei der mittlerweile als Deprecated gekennzeichneten Klasse Date war das allerdings auch schon so...

getMonth

public int getMonth()

Deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.MONTH).

Returns a number representing the month that contains or begins with the instant in time represented by this Date object. The value returned is between 0 and 11, with the value 0 representing January.

Und bei der Klasse Calendar auch:

MONTH

public static final int MONTH

Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year is JANUARY which is 0; the last depends on the number of months in a year.

Quelle: java.sun.com

Hm, also mir ist auch noch nie was anderes unter die Augen gekommen. Wo willst du denn mal gesehen haben, dass das anders ist?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.