#Time Data Type
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
i'm using postgres if that matters
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
cant you save it as a string or integer then ?
Postgres has a timestamp type.
Or are you looking for a LocalTime equivalent?
- Java
Instant<-> Postgrestimestamp - Java
LocalDate<-> Postgresdate - Java
LocalTime<-> Postgrestime
The java.sql package offers Timestamp, Date and Time but they're pretty ugly to work with.
yeah postgres has timestamp
i was using getDate
i didn't realize resultset has getTimestamp
what would be a reason to save in LocalDate instead of Instant
scheduling something at 3:14pm every week is not an 'instant'. Similarly the date 21st April 2023 can be timezone independent. Also, the date spans all of the instants with that date in a given timezone. All of these subtleties are useful in differing scenarios.
An instant should be thought of as a specific record at a point in time, that is timezone independent. A ZonedDateTime would be a specific instant with timezone information, a LocalDateTime would be point in time without timezone information (so that point in time occurred/occurred at different instants for different locations).
LocalDateTime is more accurate to what is stored than instant
Instant is the correct class to use within ur java code
u should stick to Instant as long as possible
and convert at the latest point necessary
unless u want to save date/time information that is not supposed to be placed on the timeline
such as an users birthday
that would be LocalDate
or an users favorite time to get up in the morning
thats LocalTime
in case u also need to remember the timezone of the user (thats rarely appropriate), u would use ZonedDateTime instead of Instant
here is an overview with examples of all the types:
#today-i-teach message