- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to display date and time information in uppercase
Firstly, create a formatter and a Calendar object.
Formatter f = new Formatter(); Calendar c = Calendar.getInstance();
To display complete date and time information uses the ‘c’ conversion character. However, to display it in uppercase, use ‘Tc’.
f = new Formatter(); System.out.println(f.format("
Date and Time (uppercase): %Tc
", cal));
The following is an example −
Example
import java.util.Calendar; import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar cal = Calendar.getInstance(); System.out.println("Current date and time: "+cal.getTime()); f = new Formatter(); System.out.println(f.format("
Date and Time (uppercase): %Tc
", cal)); } }
Output
Current date and time: Mon Nov 26 07:44:39 UTC 2018 Date and Time (lowercase): MON NOV 26 07:44:39 UTC 2018
Advertisements