
正文
java记事本时间代码 java记事本代码运行
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
java如何创建以日期为命名的记事本
可以通过“FileOutputStream”创建文件实例,之后过“OutputStreamWriter”流的形式进行存储,举例:
OutputStreamWriter pw = null;//定义一个流
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
String date = df.format(new Date());// new Date()为获取当前系统时间
pw = new OutputStreamWriter(new FileOutputStream(“D:/"+date +".txt”),"GBK");//确认流的输出文件和编码格式,此过程创建了“日期.txt”实例
pw.write("我是要写入到记事本文件的内容");//将要写入文件的内容,不写这句就是创建空的
pw.close();//关闭流
备注:文件流用完之后必须及时通过close方法关闭,否则会一直处于打开状态,直至程序停止,增加系统负担。
相关问答
Q1: 急求一份用JAVA编写的日历记事本,用Eclipse实现,包括日历,记事本,时钟啊
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class CalenderTrain extends JFrame implements ActionListener {
private static final long serialVersionUID=1L;
private static final int new_year = 0;
private JComboBox MonthBox =new JComboBox();
private JComboBox YearBox=new JComboBox();//月份和年份java记事本时间代码的下拉列表框
private JLabel YearLabel=new JLabel("年份");
private JLabel MonthLabel=new JLabel("月份");//月份和年份的标签
private JButton button_ok=new JButton("查看");
private JButton button_today=new JButton("今天");// “查看”和“今天”两个按钮
private Date now_date=new Date();
@SuppressWarnings("deprecation")
private int now_year=now_date.getYear()+1900;
@SuppressWarnings("deprecation")
private int now_month=now_date.getMonth();// 获取今天的日期,年份,月份
@SuppressWarnings("unused")
private boolean tidayFlag=false;//是否显示今天的日期
private JButton [] button_day=new JButton[42];
private final String[] week={"日","一","二","三","四","五","六"};
private JButton[] button_week=new JButton[7];//用一组按钮显示日期,一行7行7列,第一行为星期的名字
private String year_int=null;//保存用户选择的年份
private int month_int;//保存用户选择的月份
private boolean todayFlag;
/**
**构造函数
*/
public CalenderTrain(){
super();
System.out.print(now_month);
this.setTitle("日历");//设置标题
this.init();
this.setLocation(500,300);
this.setResizable(true);//设置面板的大小不能变化
pack();
}
/**
*
* 初始化日历
*/
private void init() {
Font font=new Font("Dialog",Font.BOLD,14);
YearLabel.setFont(font);
MonthLabel.setFont(font);
button_ok.setFont(font);
button_today.setFont(font);
for(int i=new_year-10;i=now_year+20;i++){
YearBox.addItem(i+"");
}//设定年份区间,为当前年份的过去10年到当前年份的未来20 年
YearBox.setSelectedIndex(10);//设定年份下拉列表为当前年份,当前年份处于第10项
for(int i=1;i12;i++){
MonthBox.addItem(i+"");
}//设定月份区间,12个月
MonthBox.setSelectedIndex(now_month);//设定月份下拉表框为当前月份
JPanel panel_ym=new JPanel();//放置下拉列表框和控制按钮的面板
panel_ym.add(YearLabel);
panel_ym.add(YearBox);
panel_ym.add(MonthLabel);
panel_ym.add(MonthBox);
panel_ym.add(button_ok);
panel_ym.add(button_today);
button_ok.addActionListener(this);
button_today.addActionListener(this);// 为两个按钮添加事件监听器
JPanel panel_day=new JPanel();//放置日期面板
panel_day.setLayout(new GridLayout(7,7,3,3));//网格布局管理器,7行7列,网格之间水平和垂直方向间均为5
for(int i=0;i7;i++){
button_week[i]=new JButton("");
button_week[i].setText(week[i]);
button_week[i].setForeground(Color.red);
panel_day.add(button_week[i]);
}//添加星期的名字,并放到面板里面
button_week[0].setForeground(Color.red);
button_week[6].setForeground(Color.red);
for(int i=0;i42;i++){
button_day[i]=new JButton("");
panel_day.add(button_day[i]);
}//添加日期,放到面板里面
this.paintDay();//显示当前年月的日期
JPanel panel_main=new JPanel();//放置以上两个面板
panel_main.setLayout(new BorderLayout());//边界布局管理器
panel_main.add(panel_day,BorderLayout.SOUTH);
panel_main.add(panel_ym,BorderLayout.NORTH);
getContentPane().add(panel_main);
}
/**显示当前年月的日期*/
@SuppressWarnings("deprecation")
private void paintDay() {
if(this.todayFlag){
year_int=now_year+"";
month_int=now_month;//要求显示今天的日期
}else{
year_int=YearBox.getSelectedItem().toString();//否则,从下拉框中获取用户的年月
month_int=MonthBox.getSelectedIndex();//被选的序号
}
int year_sel=Integer.parseInt(year_int)-1900;//获得年份置
@SuppressWarnings({ })
Date firstDay=new Date(year_sel,month_int,1);//构造该余额的第一天
GregorianCalendar cal=new GregorianCalendar();//创建一个Calendar的实例
cal.setTime(firstDay);
int days=0;//存放某个月份的天数
int day_week=0;//存放某个月份的第一天使星期几色数值
if(month_int==0||month_int==2||month_int==4||month_int==6||month_int==7||month_int==9||month_int==11){
days=31;
}else if(month_int==3||month_int==5||month_int==8||month_int==10){
days=30;
}else{
if(cal.isLeapYear(year_sel)){
days=29;
}else{
days=28;
}//二月,如果闰年,则有29天,否则有28java记事本时间代码他
}//判断是几月份,根据它来设定day的值,其中二月份要判断是否闰年
day_week=firstDay.getDay();
int count=1;
/**
* 绘制按钮。在这里首先要根据选定的月份的第一天是星期几来确定绘制按钮的起始位置
* 其中day_week就是我们要绘制的起始位置,对于那些没有数值可以显示的按钮要置空
*/
for(int i=day_week;iday_week+days;count++,i++){
if(i%7==0||i==6||i==13||i==20||i==27||i==34||i==41){
//如果是边界上的按钮,文字用红色,以来标示周末
if(i==day_week+now_date.getDate()-1){
button_day[i].setForeground(Color.blue);//将与今天一样的日期用蓝色标示
button_day[i].setText(count+"");
}else{
button_day[i].setForeground(Color.red);//其它边界上的按钮中的文字用红色
button_day[i].setText(count+"");
}
}else{
if(i==day_week+now_date.getDate()-1){
button_day[i].setForeground(Color.blue);//将与今天一样的日期用蓝色标示
button_day[i].setText(count+"");
}else{
button_day[i].setForeground(Color.black);//一般位置的按钮上的文字用黑色标示
button_day[i].setText(count+"");
}
}
}
if(day_week==0){
//对于没有日期数值显示的按钮进行置空处理
for(int i=days;i42;i++){
button_day[i].setText("");//如果第一天是周日,则将第一天前面的按钮置空
}
} else{
for(int i=0;iday_week;i++){
button_day[i].setText("");//如果第一天不是周日,则将第一天前面的按钮置空
}
}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button_ok){
//如果单击“查看”按钮就调用setDay()重新方法绘制按钮
this.todayFlag=false;
this.paintDay();
}else if(e.getSource()==button_today){
//如果单击“今天”按钮,得到今天的日期
todayFlag=true;
YearBox.setSelectedIndex(10);
MonthBox.setSelectedIndex(now_month);
this.paintDay();
}
}
/**
* @param args
*/
public static void main(String[] args){
CalenderTrain ct=new CalenderTrain();
ct.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ct.setVisible(true);
}
}
Q2: Java代码中如何获得当前时间
有两种方法java记事本时间代码:
方法一java记事本时间代码:用java.util.Date类来实现java记事本时间代码,并结合java.text.DateFormat类来实现时间的格式化java记事本时间代码,看下面代码:
import java.util.*;
import java.text.*;
//以下默认时间日期显示方式都是汉语语言方式
//一般语言就默认汉语就可以了,时间日期的格式默认为MEDIUM风格,比如:2008-6-16 20:54:53
//以下显示的日期时间都是再Date类的基础上的来的,还可以利用Calendar类来实现见类TestDate2.java
public class TestDate {
public static void main(String[] args) {
Date now = new Date();
Calendar cal = Calendar.getInstance();
DateFormat d1 = DateFormat.getDateInstance(); //默认语言(汉语)下的默认风格(MEDIUM风格,比如:2008-6-16 20:54:53)
String str1 = d1.format(now);
DateFormat d2 = DateFormat.getDateTimeInstance();
String str2 = d2.format(now);
DateFormat d3 = DateFormat.getTimeInstance();
String str3 = d3.format(now);
DateFormat d4 = DateFormat.getInstance(); //使用SHORT风格显示日期和时间
String str4 = d4.format(now);
DateFormat d5 = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL); //显示日期,周,时间(精确到秒)
String str5 = d5.format(now);
DateFormat d6 = DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG); //显示日期。时间(精确到秒)
String str6 = d6.format(now);
DateFormat d7 = DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT); //显示日期,时间(精确到分)
String str7 = d7.format(now);
DateFormat d8 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM); //显示日期,时间(精确到分)
String str8 = d8.format(now);//与SHORT风格相比,这种方式最好用
System.out.println("用Date方式显示时间: " + now);//此方法显示的结果和Calendar.getInstance().getTime()一样
System.out.println("用DateFormat.getDateInstance()格式化时间后为:" + str1);
System.out.println("用DateFormat.getDateTimeInstance()格式化时间后为:" + str2);
System.out.println("用DateFormat.getTimeInstance()格式化时间后为:" + str3);
System.out.println("用DateFormat.getInstance()格式化时间后为:" + str4);
System.out.println("用DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL)格式化时间后为:" + str5);
System.out.println("用DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG)格式化时间后为:" + str6);
System.out.println("用DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT)格式化时间后为:" + str7);
System.out.println("用DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM)格式化时间后为:" + str8);
}
}
运行结果:
用Date方式显示时间: Mon Jun 16 20:54:53 CST 2008
用DateFormat.getDateInstance()格式化时间后为:2008-6-16
用DateFormat.getDateTimeInstance()格式化时间后为:2008-6-16 20:54:53
用DateFormat.getTimeInstance()格式化时间后为:20:54:53
用DateFormat.getInstance()格式化时间后为:08-6-16 下午8:54
用DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL)格式化时间后为
:2008年6月16日 星期一 下午08时54分53秒 CST
用DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG)格式化时间后为
:2008年6月16日 下午08时54分53秒
用DateFormat.getDateTimeInstance(DateFormat.SHORT,DateFormat.SHORT)格式化时间后
为:08-6-16 下午8:54
用DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM)格式化时间
后为:2008-6-16 20:54:53
方法二:用java.util.Calendar类来实现,看下面:
import java.util.*;
import java.text.*;
//以下是利用Calendar类来实现日期时间的,和Date类相比较比较简单
public class TestDate2 {
public static void main(String[] args) {
Calendar ca = Calendar.getInstance();
int year = ca.get(Calendar.YEAR);//获取年份
int month=ca.get(Calendar.MONTH);//获取月份
int day=ca.get(Calendar.DATE);//获取日
int minute=ca.get(Calendar.MINUTE);//分
int hour=ca.get(Calendar.HOUR);//小时
int second=ca.get(Calendar.SECOND);//秒
int WeekOfYear = ca.get(Calendar.DAY_OF_WEEK);
System.out.println("用Calendar.getInstance().getTime()方式显示时间: " + ca.getTime());
System.out.println("用Calendar获得日期是:" + year +"年"+ month +"月"+ day + "日");
System.out.println("用Calendar获得时间是:" + hour +"时"+ minute +"分"+ second +"秒");
System.out.println(WeekOfYear);//显示今天是一周的第几天(我做的这个例子正好是周二,故结果显示2,如果你再周6运行,那么显示6)
}
}
运行结果是:
用Calendar.getInstance().getTime()方式显示时间: Mon Jun 16 21:54:21 CST 2008
用Calendar获得日期是:2008年5月16日
用Calendar获得时间是:9时54分21秒
2
总结:中的来说,方法二是最方便的,方法一显得分笨拙,不过看个人喜欢了。
还有一种方法利用System.currentTimeMillis()也可以。
Q3: java做日历记事本
3.2设计要求
(1)界面的左侧是日历。该日历可以按年前后翻动,当鼠标单击“上一年”按钮时,当前日历的年份将减一;当鼠标左键单击“下年”按钮,当前日历的年份将加一。
(2)也可以在某年内按月前后翻动。当鼠标左键单击“上月”按钮时,当前日历的月份将减一;当鼠标左键单击“下月” 当前日历表的月份将加一。
(3)使用鼠标左键在要选择的日期上单击,如有记事内容,程序将弹出对话框提示该日有记事内容,提示用户是否用记事本显示该内容。
(4)选择具体日期后,可以将记事本的内容保存起来,形成一个日志。
3.3系统的主要功能
(1)可以进行日期查询;
(2)可以方便地在任何日期记载有关内容以及查看某个日期记载的内容 。
这个怎么样,完整的课程设计,不过你给的分太少啦,想要的话加点分,把邮箱给我,分加上,我发给你
Q4: java 编程中显示日期和时间的代码
可以直接通过jdk基本方法java记事本时间代码,获取到当前java记事本时间代码的时间
Date date= new Date();//创建一个时间对象,获取到当前的时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置时间显示格式
String str = sdf.format(date);//将当前时间格式化为需要的类型
System.out.println(str);//输出结果
结果为java记事本时间代码:2015-11-06 13:53:54(实时)。
Q5: 用JAVA编个简单的记事本程序
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.util.Calendar;
import java.util.Date;
import javax.swing.*;
class Editor extends Frame implements ActionListener,ItemListener
{
// Date date=new Date();
int n1;String str="";int k=0;String st1,st2;
JTextArea ta=new JTextArea(50,50);
Dialog dialog,dialog1;
Choice ce1,ce2,ce3;
Button btn1,btn2,btn3;Panel p1=new Panel();
Panel p2=new Panel();Panel p3=new Panel();Panel p4=new Panel();
public Editor (String s)
{
super ("记事本编辑板");
ImageIcon YouImg = new ImageIcon("iconimage.jpg");
setIconImage(YouImg.getImage());
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
setBounds(50,35,700,500);
MenuBar mb=new MenuBar();
setMenuBar(mb);
Menu file=new Menu("文件(F)");Menu edit=new Menu("编辑(E)");Menu help=new Menu("帮助(H)");
Menu pattern=new Menu("格式(P)");Menu time=new Menu("时间(T)");
MenuItem exit=new MenuItem("退出",new MenuShortcut(KeyEvent.VK_Q));
MenuItem tdate=new MenuItem("日期/时间",new MenuShortcut(KeyEvent.VK_D));
MenuItem renew=new MenuItem("新建", new MenuShortcut(KeyEvent.VK_N));
MenuItem save=new MenuItem("保存", new MenuShortcut(KeyEvent.VK_S));
MenuItem open=new MenuItem("打开",new MenuShortcut(KeyEvent.VK_O));
MenuItem copy=new MenuItem("复制",new MenuShortcut(KeyEvent.VK_C));
MenuItem paste=new MenuItem("粘贴",new MenuShortcut(KeyEvent.VK_V));
MenuItem cut=new MenuItem("剪切",new MenuShortcut(KeyEvent.VK_X));
MenuItem helptopic=new MenuItem("主题",new MenuShortcut(KeyEvent.VK_T));
helptopic.addActionListener(this);
dialog=new Dialog(this, "字体设置");dialog.setSize(300,300);
dialog1=new Dialog(this, "帮助主题");dialog1.setBounds(250,100,300,400);
dialog.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dialog.setVisible(false);}
});
dialog1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dialog1.setVisible(false);}
});
//dialog.setBackground(Color.WHITE);
dialog.setLayout(null);dialog.setBounds(170,150,450,300);
Label L1=new Label("字体(F)");Label L2=new Label("字形(Y)");
Label L3=new Label("大小(S)");TextArea ta1=new TextArea(5,5);
ta1=new TextArea("至于记事本java记事本时间代码的主题嘛,因为本人java记事本时间代码的水平有限, 所有不能为大家作过多的指导,望大家见谅!"); //在这里我想加一个文本框用来放帮助信息。
ce1=new Choice();ce2=new Choice();
ce3=new Choice();
btn1=new Button("确定");btn2=new Button("取消");btn1.addActionListener(this);btn2.addActionListener(this);
btn3=new Button("颜色");
btn3.addActionListener(this);
ce1.add("华文行楷");ce1.add("华文中宋");ce1.add("华文新魏");ce1.add("华文细黑");ce1.add("宋体");ce1.add("方正姚体");
ce1.add("幼圆");ce1.add("隶书");ce1.add("楷体-GB2312");ce1.add("华文行楷");ce1.add("华文彩云");ce1.add("仿宋-GB2312");
ce2.add("粗体");ce2.add("斜体");ce2.add("常规");
for(int n1=0;n1=100;n1++)
{ce3.add(""+n1);}
dialog.add(p1);p1.setBounds(5,30,440,35);p1.setLayout( null);//p1.setBackground(Color.red);
dialog.add(p2);p2.setBounds(5,65,440,27);dialog.add(p3);p3.setBounds(5,90,440,40);//p4.setBounds(5,120,440,138);
p1.setLayout( null);
p1.add(L1);L1.setBounds(5,15,50,25);p1.add(L2);L2.setBounds(150,15,50,25);
p1.add(L3);L3.setBounds(250,15,50,25);p2.setLayout( null);//p2.setBackground(Color.yellow);
p2.add(ce1);ce1.setBounds(5,0,130,25);p2.add(ce2);ce2.setBounds(160,0,90,25);p2.add(ce3);ce3.setBounds(260,0,75,25);
p2.add(btn1);btn1.setBounds(360,0,75,25);
p3.setLayout( null);p3.add(btn2);btn2.setBounds(360,10,75,25);p3.add(btn3);btn3.setBounds(160,10,75,25);
dialog.add(p4);p4.setBackground(Color.yellow);p4.setBounds(5,120,440,138);
dialog1.add(ta1);
//设置字体的下拉情况
MenuItem Font=new MenuItem("字体");//给字体加监听器
Font.addActionListener(this);
MenuItem Replace=new MenuItem("替换"); MenuItem Seek=new MenuItem("查找");
//首要添加组件的情况
mb.add(file);mb.add(edit);mb.add(pattern);mb.add(time);mb.add(help);
file.add(renew);file.addSeparator();file.add(open);time.add(tdate);
file.addSeparator(); file.add(exit);file.addSeparator();file.add(save);
edit.add(copy); edit.addSeparator();edit.add(paste);edit.addSeparator();edit.add(cut);
pattern.add(Font); pattern.add(Replace);
pattern.add(Seek);help.add(helptopic);
//给必要的组件加上监听器
renew.addActionListener( this);tdate.addActionListener(this);
open.addActionListener(this); save.addActionListener(this);exit.addActionListener(this);
cut.addActionListener(this);copy.addActionListener(this);paste.addActionListener(this);
ce1.addItemListener(this);ce2.addItemListener(this);ce3.addItemListener(this);
//添加必要的组件
add(ta,"Center");ta.setBackground(new Color(249,255,234));
setSize(700,500);
setVisible(true);
this.validate() ;
}
public void itemStateChanged(ItemEvent e) {
if (ce2.getSelectedItem().equals("粗体"))
{ k=1;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}
if (ce2.getSelectedItem().equals("斜体"))
{ k=2;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}
if (ce2.getSelectedItem().equals("常规"))
{ k=3;st1=ce1.getSelectedItem();st2=ce3.getSelectedItem();}
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("新建"))
{System.out.println("new ");
ta.setText("");}
if(e.getActionCommand().equals("退出"))
{ System.exit(0);}
try
{
if(e.getActionCommand().equals("打开"))
openText();
if(e.getActionCommand().equals("保存"))
saveText();
}catch(IOException e1){}
if(e.getActionCommand().equals("复制"))
{ str=ta.getSelectedText();}
if(e.getActionCommand().equals("粘贴"))
{ ta.insert(str,ta.getCaretPosition());}
if(e.getActionCommand().equals("剪切"))
{str=ta.getSelectedText();ta.replaceRange("",ta.getSelectionStart(),ta.getSelectionEnd());
}
if(e.getActionCommand().equals("字体"))
{dialog.setVisible(true);}
if(e.getActionCommand().equals("主题"))
{dialog1.setVisible(true);}
if(e.getActionCommand().equals("颜色"))
{
Color clr=JColorChooser.showDialog(this,"颜色对话框",null);
ta.setForeground(clr);
}
if(e.getSource()==btn2)
dialog.setVisible(false);
if(e.getSource()==btn1)
{
if(k==1)
{ ta.setFont(new Font(st1,Font.BOLD,Integer.parseInt(st2)));}
if(k==2)
{ ta.setFont(new Font(st1,Font.ITALIC,Integer.parseInt(st2)));}
if(k==3)
{ ta.setFont(new Font(st1,Font.PLAIN,Integer.parseInt(st2)));}
dialog.setVisible(false);
}
//if (e.getActionCommand().equals("日期/时间"))
//ta.setText(ta.getText()+""+date);
if(e.getActionCommand().equals("日期/时间"))
{
Calendar c1 =Calendar.getInstance();
int y = c1.get(Calendar.YEAR);
int m = c1.get(Calendar.MONTH);
int d = c1.get(Calendar.DATE);
int h = c1.get(Calendar.HOUR);
int m1 = c1.get(Calendar.MINUTE);
int m2 = m+1;
ta.setText(ta.getText()+""+(y+"年"+m2+"月"+d+"日"+h+":"+m1));
}
}
public void openText() throws IOException
{
FileDialog fd=new FileDialog(this,"打开文件对话框",FileDialog.LOAD);
fd.setVisible(true);FileInputStream fis=new FileInputStream(fd.getDirectory()+fd.getFile());
ta.setText("");
int n=0;
while((n=fis.read())!=-1)
ta.append(""+(char)n);
fis.close();
}
public void saveText() throws IOException
{
FileDialog fd=new FileDialog(this,"打开文件对话框",FileDialog.SAVE);
fd.setVisible(true);
FileOutputStream out=new FileOutputStream(fd.getDirectory()+fd.getFile()+".txt");
String str=ta.getText();
String str1=ta.getText();
for(int n=0;nstr.length();n++)
out.write((byte)str.charAt(n));
out.close();
}
public static void main(String[] args)
{
Editor f=new Editor(" 记事本程序");
//添加时间代码
Date date=new Date();
System.out.print(date);
/*Calendar now=Calendar.getInstance();
int year=now.get(Calendar.YEAR);
int month=now.get(Calendar.MONTH)+1;
int day=now.get(Calendar.DATE);
System.out.print(year+"年"+month+"月"+day+"日");
int week=now.get(Calendar.DAY_OF_WEEK);
String str="日一二三四五六";//星期1-7
int i=2*(week-1);
System.out.println("星期"+str.substring(i,i+2));//对应中文的下标*/
}
class dialog extends Dialog
{
public dialog()
{
super(dialog, "字体设置");
class Mycanvas extends Canvas
{
Toolkit tk;
Image img;
Mycanvas()
{
setSize(440,138);
tk=getToolkit();
img=tk.getImage("photo.jpg");
}
public void paint(Graphics g)
{
g.drawImage(img,5,120,440,138,this);
}
}
}
}
}
java记事本时间代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java记事本代码运行、java记事本时间代码的信息别忘了在本站进行查找喔。








