Import java. util .*;
Public class D
{
Public static void main (String [] abc)
{
Int y, m, d, h, mi, s;
Calendar cal = Calendar. getInstance ();
Y = cal. get (Calendar. YEAR );
M = cal. get (Calendar. MONTH );
D = cal. get (Calendar. DATE );
H = cal. get (Calendar. HOUR_OF_DAY );
Mi = cal. get (Calendar. MINUTE );
S = cal. get (Calendar. SECOND );
System. out. println ("the current time is" + y + "year" + m + "month" + d + "day" + h + "Hour" + mi + "Minute" + s + "seconds ");
}
}
######################################## ##################################
Public class Main {
Public static void main (String [] args ){
Java. util. Calendar c = java. util. Calendar. getInstance ();
Java. text. SimpleDateFormat f = new java. text. SimpleDateFormat ("MM dd, yyyy, hh, mm, ss seconds ");
System. out. println (f. format (c. getTime ()));
}
}
######################################## ##################################
Public String GetNowDate (){
String temp_str = "";
Date dt = new Date ();
// The Last aa indicates "Morning" or "Afternoon" HH indicates the 24-hour system. If it is changed to hh, it indicates the 12-hour system.
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss aa ");
Temp_str = sdf. format (dt );
Return temp_str;
}