Java How to get Current System Date and Time is explained below;
 
new Date() will return the instance of current date and time.
Using java.text.SimpleDateFormat you can format the date and time how ever you like to return as below;
 

public static String getCurrentDateTimeString(){
	    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		
	    Date now = new Date();
	    String strDate = sdfDate.format(now);
	    
	    return strDate;
}

 
If you execute above code output in the console will be as below;

2017/06/16 22:58:35

 
For further reading refer Java Programming Category posts.

Share this post

Java How to get Current System Date and Time
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *