date to string java
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
String strDate = dateFormat.format(date);
date to string java
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
String strDate = dateFormat.format(date);
date format in java
String pattern = "yyyy-MM-dd";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
String date = simpleDateFormat.format(new Date());
System.out.println(date);
Java convert date to string
// java convert date to string
import java.util.Date;
import java.text.SimpleDateFormat;
public class DateToStringDemo
{
public static void main(String[] args)
{
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
String strDate = sdf.format(dt);
System.out.println("Date format - MM/dd/yyyy to string is : " + strDate);
sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
strDate = sdf.format(dt);
System.out.println("Date format - dd-M-yyyy hh:mm:ss to string is : " + strDate);
sdf = new SimpleDateFormat("dd MMMM yyyy");
strDate = sdf.format(dt);
System.out.println("Date format - dd MMMM yyyy to string is : " + strDate);
sdf = new SimpleDateFormat("dd MMMM yyyy zzzz");
strDate = sdf.format(dt);
System.out.println("Date format - dd MMMM yyyy zzzz to string is : " + strDate);
sdf = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z");
strDate = sdf.format(dt);
System.out.println("Date format - E, dd MMM yyyy HH:mm:ss z to string is : " + strDate);
}
}
java date to string
Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = formatter.format(date);
date format in java
Locale locale = new Locale("en", "UK");
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
dateFormatSymbols.setWeekdays(new String[]{
"Unused",
"Sad Sunday",
"Manic Monday",
"Thriving Tuesday",
"Wet Wednesday",
"Total Thursday",
"Fat Friday",
"Super Saturday",
});
String pattern = "EEEEE MMMMM yyyy";
SimpleDateFormat simpleDateFormat =
new SimpleDateFormat(pattern, dateFormatSymbols);
String date = simpleDateFormat.format(new Date());
System.out.println(date);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us