TL; dr
myJavaUtilDate // The terrible 'java.util.Date' class is now legacy. Use *java.time* instead. .toInstant() // Convert this moment in UTC from the legacy class 'Date' to the modern class 'Instant'. .atZone( ZoneId.of( "Africa/Tunis" ) ) // Adjust from UTC to the wall-clock time used by the people of a particular region (a time zone). .toLocalDate() // Extract the date-only portion. .atStartOfDay( ZoneId.of( "Africa/Tunis" ) ) // Determine the first moment of that date in that zone. The day does *not* always start at 00:00:00.
java.time
You are using the horrible old date and time classes that were superseded several years ago by the modern java.time classes defined in JSR 310.
Date β Instant
java.util.Date represents the moment in UTC. Its replacement is Instant . Call the new conversion methods added to the old classes.
Instant instant = myJavaUtilDate.toInstant() ;
Timezone
Indicate the time zone in which you want your new time of day to make sense.
Enter the correct time zone name in Continent/Region format, for example, America/Montreal , Africa/Casablanca or Pacific/Auckland . Never use a 2-4 letter abbreviation, such as EST or IST as they are not true time zones, not standardized, and not even unique (!).
ZoneId z = ZoneId.of( "America/Montreal" ) ;
ZonedDateTime
Apply ZoneId to Instant to get ZonedDateTime . The same moment, the same point on the timeline, but a different wall clock time.
ZonedDateTime zdt = instant.atZone( z ) ;
Change the time of day
You asked to change the time of day. Apply LocalTime to change all parts of the time of day: hours, minutes, seconds, fractions of a second. A new ZonedDateTime with the values ββbased on the original. The java.time classes use this immutable object pattern to ensure thread safety .
LocalTime lt = LocalTime.of( 15 , 30 ) ; // 3:30 PM. ZonedDateTime zdtAtThreeThirty = zdt.with( lt ) ;
First moment of the day
But you asked specifically for 00:00. So, apparently, you want the first moment of the day. Caution: some days in some areas do not start at 00:00:00. They may start at other times, such as 01:00:00, due to anomalies such as daylight saving time (DST).
Let java.time determine the first moment. Retrieve part for date only. Then go through the time zone to get the first moment.
LocalDate ld = zdt.toLocalDate() ; ZonedDateTime zdtFirstMomentOfDay = ld.atStartOfDay( z ) ;
Set to UTC
If you need to return to UTC, retrieve Instant .
Instant instant = zdtFirstMomentOfDay.toInstant() ;
Instant β Date
If you need java.util.Date to interact with old code that has not yet been updated to java.time, convert.
java.util.Date d = java.util.Date.from( instant ) ;