Advertisement
dimipan80

Print the Current Date and Time

Aug 17th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. // Create a simple Java program CurrentDateTime.java to print the current date and time.
  2.  
  3. import java.time.LocalDateTime;
  4. import java.util.Locale;
  5.  
  6. public class _05_PrintTheCurrentDateAndTime {
  7.  
  8.     public static void main(String[] args) {
  9.         // TODO Auto-generated method stub
  10.         Locale.setDefault(Locale.ROOT);
  11.         LocalDateTime thisDateTime = LocalDateTime.now();
  12.         System.out.printf("The Time and Date now is: %1$tH:%1$tM at %1$td/%1$tb/%1$tY.\n",
  13.                         thisDateTime);
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement