my data file and hence my stage table in hive, has time in the following format 1/1/2013 5:27:35 PM. I want to load this data into another table that has time in the TIMESTAMP data type format. So basically the above format needs to be transformed to 2013-01-01 17:27:35. How to do this ?
1 Answer
you could try in java:
String dateStart = "01/14/2012 09:29:58";
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date d1 = format.parse(dateStart);
System.out.println("Input: " + dateStart);
System.out.println("Output: " + sdf.format(d1));
} catch (ParseException e) {
e.printStackTrace();
}
Output
Input: 01/14/2012 09:29:58
Output: 2012-01-14 09:29:58