字符串转化为日期格式 如何将一个字符串转换为时间格式?
如何将一个字符串转换为时间格式?如果您想将日期输出为2005年6月9日,我们可以这样写:simpledateformat SDF=new simpledateformat(“yyy-MM-DD”)st
如何将一个字符串转换为时间格式?
如果您想将日期输出为2005年6月9日,我们可以这样写:simpledateformat SDF=new simpledateformat(“yyy-MM-DD”)string str=sdf.format格式(parse(“2005-06-09 00:00:00”)str将以我们设置的格式输出。使用的API是SimpleDataFormat,它属于java.text.SimpleDataFormat所以请记住导入!用法:simpledateformat SDF=new simpledateformat(“yyy-MM-DD HH:MM:SS”)是最重要的一行,它建立了转换的格式。Yyyy是一年中完整的一年,mm是月份,DD是日期。