Display full date time in Java
Description
The following code shows how to display full date time.
Example
/* ww w. ja va2s . c o m*/
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar now = Calendar.getInstance();
System.out.println("Current full date time is : " + (now.get(Calendar.MONTH) + 1) + "-"
+ now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR) + " "
+ now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":"
+ now.get(Calendar.SECOND) + "." + now.get(Calendar.MILLISECOND));
}
}
The code above generates the following result.