0

I'm triyng to make a program read a date from a txt file into a Date object. Here is the code I'm using :

reader = new FileReader(fich); 
rd = new Scanner(reader);
DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy");
Date tmpdate= formatter.parse(rd.nextLine());

And this is the line I want to read: Fri Feb 20 01:23:35 GMT 2015

and then it shows up this error: Exception in thread "main" java.text.ParseException: Unparseable date: "Fri Feb 20 01:23:35 GMT 2015"

what is wrong?

Ramsharan
  • 2,079
  • 2
  • 21
  • 25

1 Answers1

2

It seems that Fri and Feb are not correct names in your locale. Try specifying one where they are correct like Locale.ENGLISH.

So instead of

new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy");

use

new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy", Locale.ENGLISH);
Pshemo
  • 118,400
  • 24
  • 176
  • 257