Search code examples
postgresqlhibernatejparfc3339

RFC3339 format in PostgreSQL


I store a time as VARCHAR(30) as we can see it below:

enter image description here

I know it is far from best practices.. there is some way to convert such a string into PostgreSQL's time ?


Solution

  • Simply casting can do the trick like:

    SELECT time::timestamptz FROM table;
    

    Proof:

    SELECT '2016-08-12T15:15:01.100001Z'::timestamptz;
             timestamptz
    -------------------------------
    2016-08-12 15:15:01.100001+00
    

    (1 row)