question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DateTime withTimeAtEndOfDay

See original GitHub issue

Hi,

Would you accept a PR adding DateTime#withTimeAtEndOfDay (and probably LocalDate#toDateTimeAtEndOfDay to support it)?

I’m often in a situation where I want to find some records by receiving a date (a DateTime instance) searching in my database between the start of day of this date (using date.withTimeAtStartOfDay()) and the end of day of this date (currently using date.withTime(23, 59, 59, 999)).

Having the opposite of withTimeAtStartOfDay would help readability of this kind of code.

Regards, Matt

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
andersonnathancommented, Oct 20, 2015

I was looking for this as well, but I found another solution. I end up using .millisOfDay().withMaximumValue(). See example

endDT = endDT.withYear(year).withMonthOfYear(month)
                    .dayOfMonth().withMaximumValue()
                    .millisOfDay().withMaximumValue();
1reaction
boncheocommented, Oct 1, 2019

Use this DateTime.now().withTimeAtStartOfDay().minusSeconds(1).toDate()

Read more comments on GitHub >

github_iconTop Results From Across the Web

DateTime (Joda-Time 2.12.1 API) - Joda.org
withTimeAtStartOfDay. public DateTime withTimeAtStartOfDay(). Returns a copy of this datetime with the time set to the start of the day.
Read more >
java.time equivalent of Joda-Time `withTimeAtStartOfDay ...
In the Joda-Time library, the DateTime class offers a method withTimeAtStartOfDay to get the first moment of the day.
Read more >
org.joda.time.DateTime.withTimeAtStartOfDay java ... - Tabnine
Best Java code snippets using org.joda.time.DateTime.withTimeAtStartOfDay (Showing top 20 results out of 459) · Number of days between two dates in Joda-Time.
Read more >
Example usage for org.joda.time DateTime ... - Java2s.com
List of usage examples for org.joda.time DateTime withTimeAtStartOfDay ... Returns a copy of this datetime with the time set to the start of...
Read more >
org.joda.time.DateTime#withTimeAtStartOfDay
This page shows Java code examples of org.joda.time.DateTime#withTimeAtStartOfDay.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found