
Hi,
How can I format the date in the following pattern?
yyyy-MM-dd

import java.util.*;
import java.text.*;
class SimpleDateFormatExample
{
public static void main(String[] args)
{
Date date=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String formattedDate=sdf.format(date);
System.out.println(formattedDate);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.