Locale-specific morning/afternoon indicator in Java


Locale-specific morning/afternoon indicator is the AM/PM marker indicator.

Use the ‘p’ conversion character to display AM/PM.

System.out.printf("Morning/afternoon indicator: %tp",d);

Example

 Live Demo

import java.util.Date;
public class Demo {
   public static void main(String[] args) {
      Date d = new Date();
      System.out.printf("Morning/afternoon indicator: %tp",d);
      System.out.printf("
Morning/afternoon indicator: %Tp",d);    } }

Output

Morning/afternoon indicator: pm
Morning/afternoon indicator: PM

Updated on: 27-Jun-2020

56 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements