Linked Questions
15 questions linked to/from LocalDate to java.util.Date and vice versa simplest conversion?
479 votes
13 answers
657k views
Convert java.time.LocalDate into java.util.Date type
I want to convert java.time.LocalDate into java.util.Date type. Because I want to set the date into JDateChooser. Or is there any date chooser that supports java.time dates?
-1 votes
4 answers
2k views
get Date without time in java [duplicate]
I want to get a Date without time, but always failed. below is my codes: long curLong = System.currentTimeMillis(); curLong = curLong - curLong % TimeUnit.DAYS.toMillis(1); Date date = ...
625 votes
14 answers
685k views
Convert java.util.Date to java.time.LocalDate
What is the best way to convert a java.util.Date object to the new JDK 8/JSR-310 java.time.LocalDate? Date input = new Date(); LocalDate date = ???
645 votes
10 answers
727k views
Converting between java.time.LocalDateTime and java.util.Date
Java 8 has a completely new API for date and time. One of the most useful classes in this API is LocalDateTime, for holding a timezone-independent date-with-time value. There are probably millions ...
230 votes
20 answers
321k views
How to create a Java Date object of midnight today and midnight tomorrow?
In my code I need to find all my things that happened today. So I need to compare against dates from today at 00:00 AM (midnight early this morning) to 12:00 PM (midnight tonight). I know ... Date ...
285 votes
14 answers
310k views
Why is the Date constructor deprecated, and what do I use instead?
I come from the C# world, so not too experienced with Java yet. I was just told by Eclipse that Date was deprecated: Person p = new Person(); p.setDateOfBirth(new Date(1985, 1, 1)); Why? And what (...
235 votes
3 answers
44k views
How to use ThreeTenABP in Android Project
I'm using Android Studio 2.1.2 and my Java setup is the following: >java -version > openjdk version "1.8.0_91" > OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10....
124 votes
3 answers
133k views
How to convert LocalDate to SQL Date Java?
How do I convert a LocalDate to a java.sql.Date? Attempt: Record r = new Record(); LocalDate date = new Date(1967, 06, 22); r.setDateOfBirth(new Date(date)); This fails (won't compile) and all I can ...
81 votes
1 answer
125k views
Convert between LocalDate and sql.Date [duplicate]
What's the correct way to convert between java.sql.Date and LocalDate (in both directions) in Java 8 (or higher)?
53 votes
1 answer
24k views
Convert java.util.Date to what “java.time” type?
I have a java.util.Date object, or a java.util.Calendar object. How do I convert that to the right type in java.time framework? I have heard that we should now be doing the bulk of our business ...
16 votes
7 answers
13k views
Truncating java.util.Date to LocalDate *without* toInstant() because java.sql.Date gives UnsupportedOperationException
If I use java.util.Date's toInstant() on a variable which happens to be a java.sql.Date, I get an UnsupportedOperationException. try { java.util.Date input = new java.sql.Date(System....
10 votes
4 answers
19k views
java.util.Date(int,int,int) deprecated [duplicate]
The constructor java.util.Date(int,int,int) is deprecated. Is there a way to set a date easy as that in Java? What's the non-deprecated way to do this? Date date = new Date(2015, 3, 2);
9 votes
5 answers
11k views
joda time - add weekdays to date
Is it possible to add weekdays to joda time? For instance, if current date is Friday 01/03, date + 1 should return Monday 04/03, rather than 02/03.
2 votes
2 answers
2k views
How to Use Formatted Text Fields with LocalDate type?
I'm using swing and trying to convert one date from database, I used the master detail to generate my form! When I am using it with Date type, it's works fine, but when I try to use with LocalDate ...
0 votes
2 answers
201 views
Set Date Param in Mysql from Java
I have jsp page view and in java and I am getting datepicker value in Java Using this : LocalDate localDate = datePicker.getValue(); I am not able to set this value using query in Mysql database ...