教育路上
摘要:java使用GregorianCalendar类获得当前的时间和日期。以下是我们为大家整理的,相信大家阅读完后肯定有了自己的选择吧。
2021-06-22 09:41刘永莘
import java.awt.*; import java.util.GregorianCalendar; public class Gregorian extends Frame { public static void main(String[] args) { Gregorian gr = new Gregorian();// 创建框架对象 TextArea ta = new TextArea();// 文本区域对象 GregorianCalendar gc = new GregorianCalendar();// 日历时钟 ta.append("Year:" + gc.get(GregorianCalendar.YEAR) + "\n");// 年 ta.append("Month:" + gc.get(GregorianCalendar.MONTH) + "\n");// 月 ta.append("Day:" + gc.get(GregorianCalendar.DATE) + "\n");// 日 ta.append("Hour:" + gc.get(GregorianCalendar.HOUR) + "\n");// 时 ta.append("Minute:" + gc.get(GregorianCalendar.MINUTE) + "\n");// 分 ta.append("Second:" + gc.get(GregorianCalendar.SECOND) + "\n");// 秒 gr.add(ta, BorderLayout.CENTER);// 文本区域加入到框架中心,用边界布局 gr.setSize(300, 200); gr.setVisible(true); } }
访客的评论 2023/12/07 08:51
文中描述的是准确的吗,如何报名!