JAVA学习第8天

16 篇文章 0 订阅
11 篇文章 0 订阅

四.日期时间类:

a.从1900年1月1日00:00:00为计算机起始时间,称为“历元”

例:Date d1 =new Date (5,1,25);代表:

1905(1900+5)年2(1+1)月25日

b.long time =d.getTime();和1900年的毫秒差

c.int year =d.getYear();年-1900

  Int month=d.getMonth();月-1

int date =d.getDate();日

int hour=d.get Hour();小时

int minute=d.getMinute();分钟

Int second=d.getSecond();秒

int day=d.getDay();一周第几天(星期天为0)

  1. 格式化的类->对日期的格式化操作
    1. String pattern =“yyyy年MM月dd日hh(12小时制HH24小时制):mm:ss  E(星期)”

  SimpleDateFormat sdf =new SimpleDateFormat(pattern);//产生格式化对象

String formatDate =sdf.format(date);

System.out.print(formatDate);、、输出

                IO流

一.概念: 通过数据流、序列化和文件系统提供系统输入和输出。 a. File(String pathname)

          通过将给定路径名字符串转换为抽象路径名来创建一个新 File 实例。

b.File(String parent, String child)

          根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例。通过数据流、序列化和文件系统提供系统输入和输出。

  • 方法摘要:
          1. Public  boolean createNewFile()

         当且仅当不存在具有此抽象路径名指定名称的文件时,不可分地创建一个新的空文件

2).public  boolean mkdir()

          创建此抽象路径名指定的目录。

3).public  boolean mkdirs()

          创建此抽象路径名指定的目录,包括所有必需但不存在的父目录

4).public  boolean createNewFile()

          当且仅当不存在具有此抽象路径名指定名称的文件时,不可分地创建一个新的空文件。

5)public  boolean exists()

          测试此抽象路径名表示的文件或目录是否存在。

6). public String getName()

          返回由此抽象路径名表示的文件或目录的名称。

7).public  String getParent()

          返回此抽象路径名父目录的路径名字符串;如果此路径名没有指定父目录,则返回 null。

8).public  File getParentFile()

          返回此抽象路径名父目录的抽象路径名;如果此路径名没有指定父目录,则返回 null。

9).public  String getAbsolutePath()

          返回此抽象路径名的绝对路径名字符串

10).public  boolean delete()

          删除此抽象路径名表示的文件或目录。

11).public boolean isDire

12).public  boolean isFile()

          测试此抽象路径名表示的文件是否是一个标准文件。

13).public  File[] listFiles()

          返回一个抽象路径名数组,这些路径名表示此抽象路径名表示的目录中的文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值