-2

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 ?

2

1 Answer 1

0

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.