Snippets tagged “instant”
9 snippets use this tag.
- Convert java.time.LocalDate into java.util.Date typeJava
To convert a java.time.LocalDate into a java.util.Date type in Java, you can use the atStartOfDay() method of the LocalDate class to get a LocalDateTime object and then use the toInstant() method to convert it to an Instant object.
- Convert java.util.Date to java.time.LocalDateJava
To convert a java.util.Date object to a java.time.LocalDate object, you can use the java.time.Instant class to represent the date as an instant in time, and then use the java.time.LocalDateTime class to convert the instant to a date and time in the local
- How can I get the current date and time in UTC or GMT in Java?Java
To get the current date and time in UTC or GMT in Java, you can use the Instant class from the java.time package. The Instant class represents a single point in time in the ISO-8601 calendar system, with a resolution of nanoseconds.
- How do I convert 2018-04-10T04:00:00.000Z string to DateTime?Java
To convert a string in the format "2018-04-10T04:00:00.000Z" to a DateTime object in Java, you can use the org.joda.time.DateTime class and the DateTimeFormatter class.
- How do I get a Date without time in Java?Java
To get a java.util.Date object with the time set to 00:00:00 (midnight), you can use the toInstant() method to convert a LocalDate object to an Instant, and then use the atZone() method to convert the Instant to a ZonedDateTime object, and finally use the
- How to get current moment in ISO 8601 format with date, hour, and minute?Java
You can use the Instant class from the Java 8 java.time package to get the current moment in ISO 8601 format with date, hour, and minute.
- How to get milliseconds from LocalDateTime in Java 8Java
To get the milliseconds from a LocalDateTime object in Java 8, you can use the toInstant method and the toEpochMilli method.
- Java code for getting current timeJava
To get the current time in Java, you can use the Instant class from the java.time package.
- What is this date format? 2011-08-12T20:17:46.384ZJava
The date format "2011-08-12T20:17:46.384Z" is an ISO 8601 extended format, which is often used for exchanging date and time information in a machine-readable format.