hadoop - Parse custom datetime in Pig -


i have following string "2014-12-15 18:20:48" when parsed datetime:

a = load 'input.txt' (mydate:chararray); b = foreach generate todate(mydate) datetime; 

i error: "2014-12-15 18:20:48" malformed @ " 18:20:48" alternatively, when specify format todate(mydate, 'yyyy-mm-dd hh:mm:ss'); datetime converted "2014-12-15t18:20:48.000z" instead of "2014-12-15 18:20:48". how can resolve give me "2014-12-15 18:20:48" type datetime?

if passing string todate function, string should of iosstring format(ref [1]).

todate(iosstring)

in first case, input string not of iosstring format (t separator missing, signifies beginning of time element). if input string of iosstring format(ref [1]) work.

in second case, calling overloaded method of todate :

todate(userstring, format)

the return type of todate method datetime object.

if getting date in string , need in other format further processsing have use tostring() method on top of todate() method in desired format.

references :

  1. iostring format : http://www.w3.org/tr/note-datetime
  2. todate(): http://pig.apache.org/docs/r0.12.0/func.html#to-date
  3. tostring() : http://pig.apache.org/docs/r0.12.0/func.html#to-string

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -