Get current time and date on Android

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

How can I get the current time and date in an Android app?

Answers

You could use:

import java.util.Calendar

Calendar c = Calendar.getInstance(); 
int seconds = c.get(Calendar.SECOND);

There are plenty of constants in Calendar for everything you need. http://developer.android.com/reference/java/util/Calendar.html http://developer.android.com/reference/java/util/Calendar.html

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/5369682/get-current-time-and-date-on-android

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils