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
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements