how to get current date time in android
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String strDate = sdf.format(c.getTime());
Log.d("Date","DATE : " + strDate)
4
6
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy_HHmmss", Locale.getDefault());
String currentDateandTime = sdf.format(new Date());
System.out.println("currentDateandTime" + currentDateandTime);
Thank you!
6
0
0
8
import java.time.*;
LocalDateTime datetime = LocalDateTime.now();
Thank you!
8
0
0
3
String currentDateTimeString = java.text.DateFormat.getDateTimeInstance().format(new Date());
// textView is the TextView view that should display it
textView.setText(currentDateTimeString);
Thank you!
3
0
3.5
2
import java.time.*;
LocalDate date = LocalDate.now();
Thank you!
2
0
4.75
4
import java.util.Calendar
Date currentTime = Calendar.getInstance().getTime();
Thank you!
4
0
Are there any code examples left?
New code examples in category Other