I am using Java 7 and I am trying to parse date with a flat file.
I have the following format "30-Mar-2012 14:05:02" in the dates of this file. I can not change it, it depends on any other software.
According to this format: "dd-MMM-yyyy is using HH: mm: ss".
But for unknown reasons this is not working.
Here is a small program that regenerates this issue.
Am I doing something wrong? Is it really possible to do this? Is this an essential issue in Java about this? the explanation is here output As you can see the small form for Mers = Mers.
package javaapplication2; Import java.text.ParseException; Import java.text.SimpleDateFormat; Import java.util.Date; Import java.util.Locale; Import java.util.logging.Level; Import java.util.logging.Logger; Public class JavaApplication2 {public static zero main (string [] args) {date d = null; {SimpleDateFormat df; Df = new simple data format ("DD-MMM-YY HH: mm: SS", locale.frence); D = df.parse ("30-Mar-2012 14:05:02"); } Hold (ParseException pre) {System.err.println (ex.getMessage ()); } If (d! = Null) {System.out.println (d.toString ()); The problem does not occur when I put the original date ("s" after the "march" is the full name of "mars") french In March, this "March" and locale in the format. Also works with the US.)
dateformsmballsdefiss = new datefermatsmobile (locale. French); (For string: dfs.getShortMonths ()) {System.out.print (s + ""); }
janv What? Vr. Mers avr my gel jil ao? T SEPT Oct. Nov. D? C.
No comments:
Post a Comment