Created 12-24-2016 08:15 AM
i have a data in my HDFS,my date format in that file is Tue Dec 20 10:04:31 +0000 2016,when i create a hive table with field name created time and datatype date it store a null value. how to change that date formate in hive?
Created 12-24-2016 08:18 AM
this looks a timestamp not date, you can store this as string in hive table and retrive it using to_date() funtion,
or you can run some date transformation before inserting into hive table, it looks you are having RFC822 timestamp which you can convert into some hive known transformation like this, I am using a java program to
public class RFC822TimeStampConverter { public static void main(String[] args) { String rfcDate = "Tue, Dec 20 10:04:31 2016"; String pattern = "EEE, MMM DD HH:mm:ss YYYY"; SimpleDateFormat format = new SimpleDateFormat(pattern); try { Date javaDate = format.parse(rfcDate); System.out.println(javaDate.toString()); } catch (ParseException e) { e.printStackTrace(); } } }
Created 12-24-2016 08:18 AM
this looks a timestamp not date, you can store this as string in hive table and retrive it using to_date() funtion,
or you can run some date transformation before inserting into hive table, it looks you are having RFC822 timestamp which you can convert into some hive known transformation like this, I am using a java program to
public class RFC822TimeStampConverter { public static void main(String[] args) { String rfcDate = "Tue, Dec 20 10:04:31 2016"; String pattern = "EEE, MMM DD HH:mm:ss YYYY"; SimpleDateFormat format = new SimpleDateFormat(pattern); try { Date javaDate = format.parse(rfcDate); System.out.println(javaDate.toString()); } catch (ParseException e) { e.printStackTrace(); } } }