get date using java

Below is the java code to retrieve current date, time, hours, seconds,.....


import java.util.*;

            Calendar now = Calendar.getInstance();
             String hour = String.valueOf(now.get(Calendar.HOUR_OF_DAY));
            String minute = String.valueOf(now.get(Calendar.MINUTE));
            String second = String.valueOf(now.get(Calendar.SECOND));
            String millis = String.valueOf(now.get(Calendar.MILLISECOND));
                      

No comments:

Post a Comment