Date Format Conversion(String to Date)

import java.util.*;
import java.text.*;
public class StringToCalender {
 public static void main(String[] args) {
 try {  String str_date=“11-June-07”;
 DateFormat formatter ; 
 Date date ; 
  formatter = new SimpleDateFormat(“dd-MMM-yy”);
  date = (Date)formatter.parse(str_date); 
 Calendar cal=Calendar.getInstance();
 cal.setTime(date);
 System.out.println(“Today is ” +date );
  catch (ParseException e)
  {System.out.println(“Exception :”+e);  } 
 
 }
  




http://www.roseindia.net/java/java-conversion/StringToCalender.shtml


see
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: