Java Program to display date and time information in lowercase


Firstly, create a Formatter and a Calendar object.

Formatter f = new Formatter();
Calendar c = Calendar.getInstance();

To display complete date and time information use the ‘c’ conversion character. However, to display it in lowercase, use ‘tc’ −

f = new Formatter();
System.out.println(f.format("
Date and Time (lowercase): %tc
", cal));

The following is an example −

Example

 Live Demo

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 (lowercase): %tc
", cal)); } }

Output

Current date and time: Mon Nov 26 07:43:47 UTC 2018

Date and Time (lowercase): Mon Nov 26 07:43:47 UTC 2018

Updated on: 30-Jul-2019

112 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements