Date date = new Date();To display current time, first use getTime() method in Date class and then call format() method in class SimpleDateFormat to human readable format.
System.out.print("Current time:"+date.toString());
Date date = new Date();Remarks
SimpleDateFormat time = new SimpleDateFormat("HH:MM a");
System.out.println("Current time:"+time.format(date.getTime()));
Text provided above does not means is the model answer, and it's was posted here for an reference to somebody who interested the related knowledge only. if there is something incorrect, please leave a comment so that i can correct it or for others viewer to have an better reference, if you want know more about this topic and where is the question, concept or answer from, you can reference from information provided under the reference sub-title.
Reference:
Introduction to Java Programming, Y. Daniel Liang 10th 9.14
No comments :
Post a Comment