InterviewSolution
Saved Bookmarks
| 1. |
Display last two digits of the current year in Java |
|
Answer» To DISPLAY the last two digits of the current year, use the date character y as shown in the below example: import java.util.Date; public CLASS Example { public STATIC void main(String[] ARGS) throws Exception { Date date = new Date(); System.out.printf("Two-digit Year = %ty\n",date); } }The output display 18 for the current year 2018: Two-digit Year = 18 |
|