Working with Date and Time?

I have great trouble with understanding how to work with date and time in programming (Java/JavaScript) & databases (PostgreSQL), as well as combined in some cases. The way I understand things now is everything as a single point of data. Calculate the prime number? Just give me a number and I will give you a result. Check if a person is living in an area? Just check if his address matches with the desired area... But dates and times? It seems to add another dimension in certain cases (simple cases of course not, like substracting current time with a specified older date time). For example, how can I check the balance of a bank account at a specific date, and then also retroactively add/subtract from his balance if the invoice is older than the current date? (e.g. I have a bunch of invoices on my desk, and I didn't enter them in the system as they come, but need to go back in time and add them to the appropriate date, and make sure the calculation of balance for a given period is valid after adding it)
8 Replies
JavaBot
JavaBot13mo ago
This post has been reserved for your question.
Hey @Steadhaven! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st13mo ago
ok I don't know what the problem is but I recommend you to not use the Date class since that's old and hard to work with instead, use the classes in java.time e.g. LocalDate for a date and LocalDateTime for a datetime then you can add/subtract dates etc pretty easily or do other things
Steadhaven
SteadhavenOP13mo ago
Yeah seems pretty straight forward, but my confusion is when I want to somehow get data between two LocalDate, or retroactively change/add data at a given LocalDate and make this new data take effect in other functions that uses this data after changing it
dan1st
dan1st13mo ago
Don't do that these classes are immutable ìnstead, you can create new LocalDate objects
Steadhaven
SteadhavenOP13mo ago
No description
Steadhaven
SteadhavenOP13mo ago
meh I hate the new paint I'll try to install the old,, seems like it doesn't copy the background :s
dan1st
dan1st13mo ago
create a new LocalDate and set the variable to it
JavaBot
JavaBot13mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?