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.

Datum Zeit

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich bin gerade dabei eine Anwendung zu schreiben, wo das aktuelle Datum und Uhrzeit in die Datenbank eingetragen werden soll. Nun will ich mit Hilfe von Java das Datum und die Zeit ermitteln, in eine Variable schreiben und diese dann in meine DB speichern. Leider habe ich keine Ahnung, wie ich genau an das Datum und Uhrzeit rankomme. Danke müsste irgendwie mit getDate(), getTime() gehen???

Ich habe auch schon was von SimpleDateFormat gehört. Aber damit kann ich nur bestimmen, in welchem Format die Ausgabe erscheinen soll, oder?

hier mal wie das Datum / Zeit aussehen muss.

"dd.MM.yyyy HH:mm:ss"

Kann mir hier jemand weiterhelfen?

Vielen Dank schonmal

Cu Snopsy

Original geschrieben von snopsy

ich bin gerade dabei eine Anwendung zu schreiben, wo das aktuelle Datum und Uhrzeit in die Datenbank eingetragen werden soll.

Einfach eine timestamp Spalte hinzufügen, die wird dann automatisch gesetzt.

Original geschrieben von snopsy

hier mal wie das Datum / Zeit aussehen muss.

"dd.MM.yyyy HH:mm:ss"

Wieso speicherst du das deutsche "Alttagsformat" und nicht nach ISO-8601 so musst du ständig umrechnen oder jedesmal die Datenbank anpassen.

Nun ja, das aktuelle Datum bekommst du mit Date d = new Date();

java.util.Date()

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Gruß Jaraz

Wenn du direkten Zugriff auf das auszuführende SQL hast, kannst du alternativ auch die jeweilige DB Funktion dafür nutzen, bei Oracle z.B. "sysdate". Das sähe dann ungefähr so aus:

insert into mytable

(coltext, colnum, coldate)

values ("my text", 123, sysdate);

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.