Calculating the difference in days between two dates in Java sounds like a trivial task, but it turns out to be otherwise. To keep track of time, Java counts the number of milliseconds from the start of January 1, 1970 and this is called the epoch. Many programmers then think that subtracting the millisecond timestamps of two moments and dividing by the number of milliseconds per day is the right way to calculate the difference between two dates. The code below is as simple as it could be, but it is also as wrong. Here is why:
Just a quick and simple hint!
If you need to set the default formatting of dates throughout your whole application in Ruby on Rails, just add the following line to your "<your application>/config/environment.rb"
my_date_formats = { :default => '%d/%m/%Y' } ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(my_date_formats) ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(my_date_formats)
Recent comments
5 days 3 hours ago
3 weeks 3 days ago
4 weeks 9 hours ago
4 weeks 6 days ago
5 weeks 5 days ago
7 weeks 1 day ago
8 weeks 6 days ago
14 weeks 2 days ago
18 weeks 5 days ago
26 weeks 15 hours ago