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 format date with System.out.format
System.out.format is used in Java to format output.
Firstly, create a Calendar object −
Calendar calendar = Calendar.getInstance();
Now, use theDate-Time conversion characters to get the date, month and year −
System.out.format("%te %tB, %tY%n", calendar, calendar, calendar);
The following is the complete example −
Example
import java.util.Locale;
import java.util.Calendar;
public class TestFormat {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
System.out.format("%te %tB, %tY%n", calendar, calendar, calendar);
}
}
Output
22 November, 2018
Advertisements
