web123456

Three ways to get the current time in Java

1. Get it through Date in Util package

Date date = new Date(); SimpleDateFormat dateFormat= new
SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
System.out.println(dateFormat.format(date));

2. Get it through the Calendar of the Util package

Calendar calendar= Calendar.getInstance(); SimpleDateFormat
dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
System.out.println(dateFormat.format(calendar.getTime()));

3. Get the time through the Calendar of the Util package, and get the year, month, day, hour, minute and second respectively.

Calendar cal=Calendar.getInstance();       
int y=cal.get(Calendar.YEAR);       int m=cal.get(Calendar.MONTH);      
int d=cal.get(Calendar.DATE);       int
h=cal.get(Calendar.HOUR_OF_DAY);       int
mi=cal.get(Calendar.MINUTE);       int s=cal.get(Calendar.SECOND);

By the way, another domestic open source software Wall is very simple to build and can build personal photo walls and video walls. If you are interested, you can read the tutorial:/u014641168/article/details/129396364