Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6134435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:21:20+00:00 2026-05-23T17:21:20+00:00

If I was to given a specific java.util.Date, how can I generate a start

  • 0

If I was to given a specific java.util.Date, how can I generate a start and end of that given date. For example, I my date is August 25, 2011, then my start date would be August 25, 2011 00 00 00 and my end of date would be August 25, 2011 23 59 59

Background: (Read below if you want to know why I ask this question)

I use JPA to map date to my MySql database like this. I want the date to have time as well, so I use TemoporalType.TIMESTAMP

@Temporal(TemporalType.TIMESTAMP)
private Date dateProcess; //java.util.Date

I need to query all data given a specific date, and since date is stored as above, I need a date range to achieve what I want.

My game plan is to convert java.util.Date to JodaTime#DateTinme, then construct the start and end date there, and convert it back so that I can pass as parameters to JPQL. But it seems that JodaTime is very immutable, I cant seem to see a setter method any where.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:21:20+00:00Added an answer on May 23, 2026 at 5:21 pm

    A java.util.Date represents an instant in time, with no reference to a time zone or calendar. The same instant will have a very different start/end of day depending on the time zone of the observer.

    You could do something like:

    DateTime dateTime = new DateTime(date.getTime(), timeZone);
    LocalDate localDate = dateTime.ToLocalDate();
    
    DateTime startOfDay = localDate.toDateTimeAtStartOfDay(timeZone);
    DateTime startOfNextDay = localDate.plusDays(1).toDateTimeAtStartOfDay(timeZone);
    

    From the last two variables, you can get back to java.util.Date values if you want. Usually they’ll both be midnight, but they might not be.

    Note that you should use the start of the next day in an exclusive way, rather than the last second of the current day in an inclusive way, in order to avoid missing values such as August 25, 2011 23:59:59.500…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given a specific DateTime value, how do I display relative time, like: 2 hours
I'm looking for a way to determine if a specific tray on a given
How do I sort a list of dictionaries by a specific key's value? Given:
Given an absolute or relative path (in a Unix-like system), I would like to
Given 2 rgb colors and a rectangular area, I'd like to generate a basic
Java generates a proxy class for a given interface and provides the instance of
So I want to start and say I am new to Java programming. Here
Let's say I have an (x,y) that is always the same for the start
Given a Python object of any kind, is there an easy way to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.