How do I get the date and time on Android?

Asked 2 years ago, Updated 2 years ago, 154 views

I'd like to receive the date and time set on the device with the code, so what can I do?

time format date android formatting

2022-09-22 14:40

1 Answers

You can use a class called DateFormat.

Date date = new Date(location.getTime());
DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));


2022-09-22 14:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.