How to parse time stamps with Unicode characters in Java or Perl? -
I am trying to make my code as normal. I am trying to parse the install time of product installation. I will have two files in the product, which has a time stamp which I have to parse and other files to be the language of installation.
Similarly I'm parse the timestamp
public square ts {public static void main (string [] args) {String installTime = "2009/11/26 \ U4e0b \ u5348 04:40:54 "; // This timestamp got me from the first file. Those Unicode readers are some Chinese readers ... AM / PM I think // locale = new locale (); // Language is not set yet SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateTimeInstance (DateFormat.DEFAULT, DateFormat.DEFAULT); Date instTime = null; Try {instTime = df.parse (installTime); } Grip (ParseException E) {// TODO self generated blocking block e.printStackTrace (); } System.out.println (instTime.toString ()); }}
The output I received
parsing failed java.text.ParseException: Ineffective Date: "2009/11/26 \ u4e0b \ u5348 04:40: 54" On the "exception" main "java.lang.NullPointerException ts.main (ts.java 45)at ts.main (ts.java39) thread on java.text.DateFormat.parse (unknown source) It throws an exception and in the end when I print it, it shows some reasonable date ... wrong though. If you can explain to me on these doubts, then I really appreciate it
-
This is not the right way How to parse the Unicode characters of the timestamp?
-
If the parsing has failed, how can the installation hold some dates, though it is wrong? I know some of the Chinese, Korean time tickets, so I have set local and zoos as follows. Still the same error comes again
locale = new locale ("to");
locale = new locale ("j");
locale = new locale ("zh");
How can I do this thing in Pearl? I can not use the date :: Manip package; Is there any other way?
Your example is not a datetime stamp, so we have to define a pattern manually.
use utf8; Use Date :: Format :: CLDR (); My $ cldr = DateTime :: format :: CLDR- & gt; New (locale = & gt; 'zh_CN', pattern = & gt; yyyy / MM / dd one HH: mm: ss ',' on_error => croak,); $ Cldr-> Parse_date ('2009/11/26 下午 04:40:54'); # DateTime Objects
Comments
Post a Comment