提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如何使用Java日历类显示当前日期和时间。
import java.util.Calendar;/** from n o w j a v a . c o m - 时 代 Java**/ public class Main { public static void main(String[] args) { //use getInstance() method to get object of java Calendar class Calendar cal = Calendar.getInstance(); //use getTime() method of Calendar class to get date and time System.out.println("Today is : " + cal.getTime()); } }