dcsimg
date parse error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Paul_Tomsic
Posted On:   Wednesday, May 21, 2003 01:38 PM

why am I getting "unparseable date" on the following code import java.text.*; import java.util.*; public class myDate { public static void test(String strDate, String strPattern) { SimpleDateFormat formatter = new SimpleDateFormat(strPattern); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.US); try { // Date date = formatter.parse(strDate); Date date = df.parse(strDate); System.out.println(date.toString()); } catch(Exception e) { System.out.println(e); } } public static void main(String[] args) { String pattern = "yyyy-MM-dd"; String myDate = "7/21   More>>

why am I getting "unparseable date" on the following code

			
import java.text.*;
import java.util.*;

public class myDate {

public static void test(String strDate, String strPattern) {
SimpleDateFormat formatter = new SimpleDateFormat(strPattern);
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.US);

try {
// Date date = formatter.parse(strDate);
Date date = df.parse(strDate);
System.out.println(date.toString());
} catch(Exception e) {
System.out.println(e);
}
}

public static void main(String[] args) {
String pattern = "yyyy-MM-dd";
String myDate = "7/21/2003";
System.out.println("your date: " + myDate);
test(myDate, pattern);
}
}




Thanks, Paul    <<Less

Re: date parse error

Posted By:   David_Bates  
Posted On:   Friday, May 23, 2003 02:48 AM

erm...could it have something to do with the fact that you specify the date pattern as yyyy-MM-dd and then give it a date in the format dd/MM/yyyy?
About | Sitemap | Contact