---
title: "从string中获取date"
author: "ldz0414"
date: "2011-02-17T11:18:13Z"
tags: []
categories: ["编程语言"]
slug: "string-date"
draft: false
lastmod: "2011-02-17T11:18:13Z"
id: 908515
url: "https://0414.iteye.com/blog/908515"
---

```java

package test.poi;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ImportClass {
	public static void main(String[]args) throws ParseException{
		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss SSS"); 
		 String sdate="1985-04-08 12:24:23 234";
		 Date date=sdf.parse(sdate);
		 System.out.println(date);
		 System.out.println(sdf.format(new Date()));
	}
}

```