About 38,600,000 results
Open links in new tab
  1. Date class in Java (With Examples) - GeeksforGeeks

    Jan 2, 2019 · Date(): Creates date object representing current date and time. Date(long milliseconds) : Creates a date object for the given milliseconds since January 1, 1970, 00:00:00 GMT. Date(int year, int month, int date)

  2. How create Date Object with values in java - Stack Overflow

    Feb 11, 2014 · I need a date object for date 2014-02-11. I can't directly create it like this, Date myDate = new Date(2014, 02, 11); So I'm doing like follows, Calendar myCalendar = new GregorianCalendar(2014, 2, 11); Date myDate = myCalendar.getTime(); Is there any easy way to create date object in java?

  3. Java Date and Time - W3Schools

    Java does not have a built-in Date class, but we can import the java.time package to work with the date and time API. The package includes many date and time classes. For example: If you don't know what a package is, read our Java Packages Tutorial. To display the current date, import the java.time.LocalDate class, and use its now() method:

  4. How to initialize a variable of date type in Java?

    Dec 6, 2015 · Use Instant, replacement for java.util.Date. Instant.now() // Capture current moment as seen in UTC. If you must have a Date, convert. java.util.Date.from( Instant.now() ) java.time. The java.util.Date & .Calendar classes have been supplanted by the java.time framework built into Java 8 and later.

  5. java - Set Date in a single line - Stack Overflow

    For a date-only value, without time-of-day and without time zone, use LocalDate class. You could use new GregorianCalendar(theYear, theMonth, theDay).getTime(): Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.

  6. Convert String to Date in Java - Baeldung

    Mar 26, 2025 · In this tutorial, we’ll explore several ways to convert String objects into Date objects. We’ll start with the new Date Time API, java.time, that was introduced in Java 8 before looking at the old java.util.Date data type also used for representing dates.

  7. Creating a LocalDate with Values in Java - Baeldung

    Jan 8, 2024 · Creating a date in Java had been redefined with the advent of Java 8. Besides, the new Date & Time API from the java.time package can be used with ease relative to the old one from the java.util package. In this tutorial, we’ll see how it makes a huge difference. The LocalDate class from the java.time package helps us achieve this.

  8. Guide to java.util.Date Class - HowToDoInJava

    Feb 17, 2022 · Learn to create new date, get current date, parse date to string or format Date object using java.util.Date class. These usecases are frequently required, and having them in one place will help in saving time for many of us. It is worth noting that there is no timezone information associated with Date instance.

  9. Java Date and Time - Online Tutorials Library

    Java provides the Date class available in java.util package, this class encapsulates the current date and time. The Date class supports two constructors as shown in the following table. This constructor initializes the object with the current date and time.

  10. Create Date Object in Java - Online Tutorials Library

    Learn how to create a Date object in Java with this comprehensive guide, covering various methods and best practices.

Refresh