
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Unix Date Format in Java
Use the ‘c’ date conversion character to display UNIX date format in Java.
System.out.printf("Unix date format: %tc",d);
Above, d is a date object.
Date d = new Date();
Example
import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d = new Date(); System.out.printf("Unix date format: %tc",d); System.out.printf("\nUnix date format: %Tc",d); } }
Output
Unix date format: Mon Nov 26 12:24:10 UTC 2018 Unix date format: MON NOV 26 12:24:10 UTC 2018
Advertisements