Blogger Information
Blog 14
fans 1
comment 1
visits 28874
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
将某个时间已固定的格式转化成字符串
bingbing的博客
Original
963 people have browsed it

QQ截图20180921110622.png

实例

//将某个时间已固定的格式转化成字符串
/*思路:
 * 
 */
import java.util.Date;
import java.text.SimpleDateFormat;

public class DateFormat {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Date now = new Date();		//得到显著的时间
		System.out.println(date2FormatStr(now));	//打印显著时间的字符串格式
	}
	//得到固定字符串格式的方法
	public static String date2FormatStr(Date date) {
		//定义字符串格式
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String str = sdf.format(date);		//进行格式化,并得到字符串
		return str;							//返回结果
	}
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post