Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Caleb Smith   on Apr 16 In Java Category.

  
Question Answered By: Jake Williams   on Apr 16

> How can I convert  11022004 to 11/02/2004.

public String getFormatedDate (String inDate, String inFormat,
String outFormat) throws ParseException {
String outDate = "";

SimpleDateFormat dtFormat = new SimpleDateFormat
(inFormat); //"ddMMyyyy"
try {
Date date  = dtFormat.parse(inDate);
dtFormat.applyPattern(outFormat); //dd/MM/yyyy
outDate = dtFormat.format(date);
}
catch (ParseException pe) {
System.err.println("Format for Entered date is
incorrect");
throw pe;
}
return outDate;
}

For formats, refer to
java.sun.com/.../SimpleDateFormat.ht
ml

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on String to String (Date conversion) Or get search suggestion and latest updates.


Tagged: