xxxxxxxxxx
import java.time.*;
LocalTime time = LocalTime.now();
xxxxxxxxxx
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)
xxxxxxxxxx
String currentDateTimeString = java.text.DateFormat.getDateTimeInstance().format(new Date());
// textView is the TextView view that should display it
textView.setText(currentDateTimeString);
xxxxxxxxxx
import java.util.Calendar;
// Get the current time
Calendar currentTime = Calendar.getInstance();
int hour = currentTime.get(Calendar.HOUR_OF_DAY);
int minute = currentTime.get(Calendar.MINUTE);
// Format the time string (optional)
String formattedTime = String.format("%02d:%02d", hour, minute);
xxxxxxxxxx
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy_HHmmss", Locale.getDefault());
String currentDateandTime = sdf.format(new Date());
System.out.println("currentDateandTime" + currentDateandTime);
xxxxxxxxxx
import java.util.Calendar
Date currentTime = Calendar.getInstance().getTime();
xxxxxxxxxx
import java.util.Calendar Date currentTime = Calendar.getInstance().getTime();
xxxxxxxxxx
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss a");
String strDate = sdf.format(c.getTime());
Log.d("TAG","DATE : " + strDate);