Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Java Program to display date with day name in short format
Firstly, set the format with SimpleDateFormat class
Format dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");
Above, the “EEE” is set to display the name of the day i.e. Monday, Tuesday, Wednesday, etc.
Now, to display the date −
String res = dateFormat.format(new Date());
The following is an example −
Example
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo {
public static void main(String[] argv) throws Exception {
Format dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");
String res = dateFormat.format(new Date());
System.out.println("Date = " + res);
}
}
Output
Date = Thu, 22/11/2018
Advertisements
