Write a java program to print current date and time in the specified format.
Current Date and Time :
June 19, 2017
3:13 pm
Java Programming Language String in java (Article) String in java (Program)
686Program:
import java.util.Calendar; public class Exercise { public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println("Current Date and Time :"); System.out.format("%tB %te, %tY%n", c, c, c); System.out.format("%tl:%tM %tp%n", c, c, c); } }
Output:
Current Date and Time : June 9, 2018 3:51 pm Press any key to continue . . .
Explanation:
This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.