B
Bill Angel
Hi:
I am having problems parsing a date
Here is a small example that illustrates the problem:
package virusAnalyzer;
import java.io.*;
import java.text.*;
import java.util.*;
public class dateFormatTest {
public static void main(String[] args) {
try {
SimpleDateFormat sdf =
new SimpleDateFormat("MMM DD hh:mm:ss yyyy",Locale.US);
Date messageDate = sdf.parse("Sep 25 21:52:14 2003");
Calendar mycal = Calendar.getInstance();
mycal.setTime(messageDate);
System.out.println("messageDate= " + mycal.getTime());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
The following line is output by the program:
messageDate= Sat Jan 25 21:52:14 EST 2003
NOTE: The date has been parsed so that the month of Jan has been
output, which is incorrect. The month of Sep should
have been written out.
I ran this program with both JDK 1.2.2 and JDK 1.3.1
and got the same result.
Is there something wrong with this code?
Thanks,
Bill Angel
I am having problems parsing a date
Here is a small example that illustrates the problem:
package virusAnalyzer;
import java.io.*;
import java.text.*;
import java.util.*;
public class dateFormatTest {
public static void main(String[] args) {
try {
SimpleDateFormat sdf =
new SimpleDateFormat("MMM DD hh:mm:ss yyyy",Locale.US);
Date messageDate = sdf.parse("Sep 25 21:52:14 2003");
Calendar mycal = Calendar.getInstance();
mycal.setTime(messageDate);
System.out.println("messageDate= " + mycal.getTime());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
The following line is output by the program:
messageDate= Sat Jan 25 21:52:14 EST 2003
NOTE: The date has been parsed so that the month of Jan has been
output, which is incorrect. The month of Sep should
have been written out.
I ran this program with both JDK 1.2.2 and JDK 1.3.1
and got the same result.
Is there something wrong with this code?
Thanks,
Bill Angel