---
title: "java.util.SimpleDateFormat String到Date 转换"
author: "chenyi.dt"
date: "2010-09-25T10:03:39Z"
tags: ["Java"]
categories: ["编程语言"]
slug: "java-util-simpledateformat-string-date"
draft: false
lastmod: "2010-09-25T10:03:39Z"
id: 770869
url: "https://chenyi-dt.iteye.com/blog/770869"
---

```java

public class DataFormatCol {

	/**
	 * 所有日期格式汇总；	
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Date date = new Date();
			String str = "Sat Sep 21 09:04:39 CST 2010";
			String str1="2010-09-25";
			String str2="2010-09-25 09:26:28";

			SimpleDateFormat sdf = new SimpleDateFormat(
					"EEE MMM dd HH:mm:ss z yyyy", Locale.US);
			date= sdf.parse(str);
			sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			System.out.println(sdf.format(date));			
			
		} catch (Exception e) {

		}

	}
}

```