将字符串转换为date类型-ag真人官方网址

大家好!今天让小编来大家介绍下关于将字符串转换为dte类型_jv字符串转dte类型的问题,以下是酷知号的小编对此问题的归纳整理,让我们一起来看看吧。

1、将字符串转换成date类型

		//字符串转date类型
        string time = "2020-02-02 02:02:02";
        simpledateformat format = new simpledateformat"yyyy-mm-dd hh:mm:ss");
        try { 
   
            date newtime = format.parsetime);
            system.out.println"转换以后的时间::"newtime);//sun feb 02 02:02:02 cst 2020
        } catch parseexception e) { 
   
            e.printstacktrace);
        }

2、将date类型转换成字符串

		//date类型转换成字符串
		simpledateformat format = new simpledateformat"yyyy-mm-dd hh:mm:ss");
        date date = new date);
        string nowtime = format.formatdate);
        system.out.println"当前的时间::"nowtime);//2020-08-25 21:28:22
		simpledateformat format = new simpledateformat"yyyy年mm月dd日");
		date date = new date);
        string nowtime = format.formatdate);
        system.out.println"当前的时间::"nowtime);//2020年08月25日
        
        simpledateformat format = new simpledateformat"yyyy年mm月dd日hh时mm分ss秒");
        date date = new date);
        string nowtime = format.formatdate);
        system.out.println"当前的时间::"nowtime);//2020年08月25日21时41分09秒

以上就是小编对于将字符串转换为dte类型_jv字符串转dte类型问题和相关问题的解答了,将字符串转换为dte类型_jv字符串转dte类型的问题希望对你有用!

© ag真人官方网址的版权声明
the end
喜欢就支持一下吧
分享
相关推荐