private static String createPostgresTimeZone ( ) { String tz = TimeZone . getDefault ( ) . getID ( ) ; if ( tz . length ( ) <= 3 || ! tz . startsWith ( "GMT" ) ) { return tz ; } char sign = tz . charAt ( 3 ) ; String start ; switch ( sign ) { case ' ' : start = "GMT-" ; break ; case ' ' : start = "GMT+" ; break ; default : // unknown type return tz ; } return start + tz . substring ( 4 ) ; }
Convert Java time zone to postgres time zone . All others stay the same except that GMT + nn changes to GMT - nn and vise versa .