第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

程序錯(cuò)誤""顯示系統(tǒng)當(dāng)前年月日時(shí)分秒 ""該怎么辦?

程序錯(cuò)誤""顯示系統(tǒng)當(dāng)前年月日時(shí)分秒 ""該怎么辦?

import java.awt.*;import java.awt.event.*;import java.util.Calendar;import javax.swing.*;public class timeTest extends JFrame{final timeTest ti=this;private JLabel label=new JLabel(); public timeTest(){this.setSize(800,400);this.setTitle("時(shí)間");this.setLayout(null);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Toolkit tk=this.getToolkit();Dimension screenSize=tk.getScreenSize();this.setLocation(screenSize.width/4-this.getWidth()/4, screenSize.height/4-this.getHeight()/4);label.setBounds(200,80,480,80); this.getContentPane().add(label); ActionListener taskPerformer=new ActionListener(){public void actionPerformed(ActionEvent e){Calendar calendar=new Calendar();label.setText(calendar.get(Calendar.YEAR) - 1900 +"年"+calendar.get(Calendar.MONTH)+"月"+calendar.get(Calendar.DAY_OF_WEEK)+"日"+ calendar.get(Calendar.HOUR_OF_DAY) +":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND));label.setFont(new Font("黑體",Font.PLAIN,25));};new Timer(1000, taskPerformer).start(); this.setVisible(true); }public static void main(String[] args) {new timeTest();}}
查看完整描述

3 回答

?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊

Date nowDate = nowTime.getTime();
public static String getTime(long time) {
Date da = new Date(time);
String dateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(da);
}

查看完整回答
反對(duì) 回復(fù) 2022-10-16
?
牧羊人nacy

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超7個(gè)贊

calendar.get(Calendar.YEAR) - 1900 +"年"+
calendar.get(Calendar.MONTH)+"月"+calendar.get(Calendar.DAY_OF_WEEK)
+"日"+ calendar.get(Calendar.HOUR_OF_DAY) +":"+calendar.get(Calendar.MINUTE)
+":"+calendar.get(Calendar.SECOND)) 改成:
SimpleDateFormat sf=new SimpleDateFormat("yyyy年-MM月-dd日 hh時(shí):mm分:ss秒");
String s=sf.format(new Date());

查看完整回答
反對(duì) 回復(fù) 2022-10-16
?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

Calendar 不是用來(lái)New 的!通過(guò)Calendar.getInstance();來(lái)創(chuàng)建的!

查看完整回答
反對(duì) 回復(fù) 2022-10-16
  • 3 回答
  • 0 關(guān)注
  • 185 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)