package cn.heima.day01.demo2;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
//将1993-03-01转换为1993年03月01日
public class test05 {
public static void main(String[] args) throws ParseException {
//创建sdf对象,格式是2018-03-04
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//将字符串“2018-03-04”-->Date对象
Date date = sdf.parse("2018-03-04");
//创建sdf1对象,格式是2018年03月04日
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日");
//将Date-->String(1993年03月01日)
String format = sdf1.format(date);
System.out.println("format = " + format);
}
}
将1993-03-01转换为1993年03月01日
猜你喜欢
转载自blog.csdn.net/weixin_43900598/article/details/84708007
今日推荐
周排行