SimDateFormat和System类

  • SimDateFormat是一个以语言环境有关的方式来格式化和解析日期的具体类

  • 进行格式化(日期-----文本),解析(文本------日期)

  • 常用的时间模式

    字母日期或时间
    y
    M
    d月中天数
    H一天中小时数(0-23)
    m分钟
    s
    S毫秒
mport java.sql.SQLOutput;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo9 {
    public static void main(String[] args)throws Exception {
        //创建SimpleDateFormat对象
        SimpleDateFormat sdf =new SimpleDateFormat("yyyy年MM月dd日");
        //创建一个date
        Date date=new Date();
        //格式化date(把日期转为字符串)
       String str= sdf.format(date);
        System.out.println(str);
        //解析(把字符串改为时间)
        Date date2=sdf.parse("2022年09月18日");
        System.out.println(date2);
    }
}

  • System类

  • Ststem系统类,主要用于获取系统的属性数据和其他操作,构造方法私有


public class Demo10 {
    public static void main(String[] args) {
        // 1 .arraycopy:数组的复制
        int[] arrays={1,23,4,5,6,8765,754,43,5,6,7};
        int[] dest=new int[11];
        System.arraycopy(arrays,0,dest,0,arrays.length);
        //原数组,从哪个位置开始复制,目标数组,目标数组的位置,复制的长度
        for (int i = 0; i < dest.length; i++) {
            System.out.print(dest[i]+"\t");
        }
        //获取当前系统的时间
        System.out.println(System.currentTimeMillis());
        long strat=System.currentTimeMillis();
        for (int i = -99999999; i <99999999 ; i++) {
            for (int j = -999999; j <99999999; j++) {
                int sum=i+j;
            }
        }
        long end=System.currentTimeMillis();
        System.out.println("用时"+(end-strat));
        //退出jvm
        System.exit(0);
        System.out.println("林夕");
    }
}

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值