I wrote the following code
Date d = new Date();
CharSequence s = DateFormat.format(\"MMMM d, yyyy \", d.getTime());
But is asking me para
try with this link of code this is absolute correct answer for all cases all over date and time. or customize date and time as per need and requirement of app.
try with this link .try with this link
CharSequence s = DateFormat.getDateInstance().format("MMMM d, yyyy ");
You need an instance first
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
// import Date class as java.util
Calendar c = Calendar.getInstance();
int day = c.get(Calendar.DAY_OF_MONTH);
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
String date = day + "/" + (month + 1) + "/" + year;
Log.i("TAG", "--->" + date);
Date c = Calendar.getInstance().getTime();
System.out.println("Current time => " + c);
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
String formattedDate = df.format(c);
This one is the best answer...
public static String getDateTime() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM dd, yyyy HH:mm:ss", Locale.getDefault());
Date date = new Date();
return simpleDateFormat.format(date);
}