<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=windows-1252"/>
	<title></title>
	<meta name="generator" content="LibreOffice 4.3.2.2 (Windows)"/>
	<meta name="author" content="Chaitrali Bubane"/>
	<meta name="created" content="2015-02-15T03:15:00"/>
	<meta name="changed" content="2015-02-24T09:55:57.359000000"/>
	<meta name="AppVersion" content="15.0000"/>
	<meta name="DocSecurity" content="0"/>
	<meta name="HyperlinksChanged" content="false"/>
	<meta name="LinksUpToDate" content="false"/>
	<meta name="ScaleCrop" content="false"/>
	<meta name="ShareDoc" content="false"/>
	<style type="text/css">
		@page { margin: 2.54cm }
		p { margin-bottom: 0.25cm; direction: ltr; line-height: 120%; text-align: left; widows: 2; orphans: 2 }
	</style>
</head>
<body lang="en-GB" dir="ltr">
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>package</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
String;</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>import</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
java.text.ParseException;</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>import</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
java.text.SimpleDateFormat;</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>import</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
java.util.Date;</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>public</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
</font></font></font><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>class</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
String_To_Date_Example {</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>public</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
</font></font></font><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>static</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
</font></font></font><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>void</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
main(String </font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">args</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">[]){</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">String
</font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">strDate</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
= </font></font></font><font color="#2a00ff"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">&quot;21/08/2011&quot;</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">;</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>try</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">{</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">SimpleDateFormat
</font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">sdf</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
= </font></font></font><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>new</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
SimpleDateFormat(</font></font></font><font color="#2a00ff"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">&quot;dd/MM/yyyy&quot;</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">);</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">Date
</font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">date</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
= </font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">sdf</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">.parse(</font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">strDate</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">);</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">System.</font></font></font><font color="#0000c0"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><i><b>out</b></i></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">.println(</font></font></font><font color="#2a00ff"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">&quot;Date
is: &quot;</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
+ </font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">date</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">);</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">}</font></font></font><font color="#7f0055"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><b>catch</b></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">(ParseException
</font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">e</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">){</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">System.</font></font></font><font color="#0000c0"><font face="Consolas, serif"><font size="2" style="font-size: 10pt"><i><b>out</b></i></font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">.println(</font></font></font><font color="#2a00ff"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">&quot;Java
String could not be converted to Date: &quot;</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">
+ </font></font></font><font color="#6a3e3e"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">e</font></font></font><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">);</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">}</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">}</font></font></font></p>
<p style="margin-bottom: 0.28cm; line-height: 107%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">}</font></font></font></p>
<p style="margin-bottom: 0.28cm; line-height: 107%"><font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">Output:-</font></font></font></p>
<p style="margin-bottom: 0cm; line-height: 100%"><a name="_GoBack"></a>
<font color="#000000"><font face="Consolas, serif"><font size="2" style="font-size: 10pt">Date
is: Sun Aug 21 00:00:00 BST 2011</font></font></font></p>
<p style="margin-bottom: 0.28cm; line-height: 107%"><br/>
<br/>

</p>
</body>
</html>