Linked Questions

479 votes
13 answers
657k views

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?
Kavinda Gehan's user avatar
-1 votes
4 answers
2k views

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 = ...
Alan's user avatar
  • 163
625 votes
14 answers
685k views

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 = ???
JodaStephen's user avatar
645 votes
10 answers
727k views

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 ...
Knut Arne Vedaa's user avatar
230 votes
20 answers
321k views

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 ...
user avatar
285 votes
14 answers
310k views

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 (...
Svish's user avatar
  • 159k
235 votes
3 answers
44k views

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....
kael's user avatar
  • 6,765
124 votes
3 answers
133k views

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 ...
Gemtastic's user avatar
  • 6,473
81 votes
1 answer
125k views

What's the correct way to convert between java.sql.Date and LocalDate (in both directions) in Java 8 (or higher)?
maja's user avatar
  • 18.2k
53 votes
1 answer
24k views

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 ...
Basil Bourque's user avatar
16 votes
7 answers
13k views

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....
Adam's user avatar
  • 5,515
10 votes
4 answers
19k views

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);
Stefan Falk's user avatar
  • 25.8k
9 votes
5 answers
11k views

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.
Bober02's user avatar
  • 15.4k
2 votes
2 answers
2k views

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 ...
Pena Pintada's user avatar
0 votes
2 answers
201 views

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 ...
Kramer's user avatar
  • 399