java-time Questions
4
Solved
How to obtain the end of the day when given a LocalDate?
I could get it by doing
LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59));
But is there an equivalent 'atStartOfDay' method f...
1
Solved
I want to convert Gregorian date to Hijri date in java 8 using HijrahChronology library.
I've tried the codes below but don't work accurately.
Date date = new Date(); // Gregorian date
Calendar c...
4
Solved
I updated to the latest Android N sdk. The only thing I don't understand is why I cannot import java.time into my code? I thought Java8 is available through Android N. Then why didn't Google add ja...
Magnificat asked 15/3, 2016 at 1:14
3
Solved
I am trying to use the Duration class instead of long.
It has superior literal syntax. I like its flexibility, though it looks weird.
"PT10S" means 10 seconds, what is the problem to accept "10 s...
14
Solved
I know there are lots of questions on SO about how to get Dates in Java, but I want an example using new Java 8 Date API. I also know about the JodaTime library, but I want a method without relying...
Intima asked 18/11, 2014 at 23:6
4
Solved
I am having a hard time converting an ISO 8601 formatted String to a java.time.LocalDateTime which is in UTC.
More specific, I am trying to write an XMLAdapter for which you can enter the various...
Mainsheet asked 10/6, 2015 at 15:5
4
java.time has an Instant class which encapsulates a position (or 'moment') on the timeline. While I understand that this is a seconds/nanoseconds value so not directly related to time zones or time...
1
Solved
I have previously been able to do this with Joda DateTime objects but i'm unsure how i can get the last day of a given month for a ZonedDateTime instance with a timezone applied.
e.g
A leap year F...
Halvah asked 23/6, 2020 at 19:32
1
Solved
The java.time framework built into Java 8 and later includes the Clock class. This class provides several variations useful for testing our date-time handling code.
Instant.now( Clock.fixed( myIns...
4
Solved
Using new Java 8 java.time API, I need to convert LocalDate and get full name of month and day. Like March (not Mar), and Monday (not Mon). Friday the 13th March should be formatted like Friday, 13...
Petrick asked 12/4, 2017 at 20:58
6
When I try to run the following code:
LocalTime test = LocalTime.parse("8:00am", DateTimeFormatter.ofPattern("hh:mma"));
I get this:
Exception in thread "main" java.time.format.DateTimeParseExc...
Taboo asked 29/9, 2017 at 1:34
3
Solved
In Instant there are methods:
toEpochMilli which converts this instant to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z
getEpochSecond which gets the number of seconds from th...
2
I want to represent a 'business date', eg a transaction that happened 'on 3 June 2019'. We actively ignore timezones for this purpose, in full knowledge that 'on 3 June 2019' in Japan might be 'on ...
Indeterminacy asked 3/6, 2019 at 9:32
3
I search for a way to get a list of Objects created on a certain LocalDateTime date saved in the Postgresql database in a field of type TIMESTAMPTZ.
To do so, I tried to use JpaRepository:
List&l...
Caprifoliaceous asked 25/5, 2020 at 7:21
4
Solved
I've got a class which contains an atttribute of java.time.LocalDateTime type.
public class MyClass{
// ...
private LocalDateTime fecha;
// ...
}
I'm using Spring Data repositories. What I wa...
Consolation asked 15/5, 2017 at 10:58
5
Solved
What is the most clean solution for adding a month to specified day using LocalDateTime or LocalDate?
Nice answers are In java.time, how is the result of adding a month calculated? and Find next o...
2
Solved
Jackson serialises java.time.Instant with WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS enabled by default.
It produces JSON like this
{ "timestamp":1421261297.356000000 }
I wonder if there's a way to g...
Greaser asked 28/5, 2019 at 15:9
1
I have this code which returns Number of week correctly.
package org.test.Calendar;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class GetDaysInMonth {
public static vo...
Aeneas asked 1/5, 2020 at 6:30
2
How can I persist Java 8 OffsetTime and OffsetDateTime with Hibernate as proper SQL types (TIME_WITH_TIMEZONE and TIMESTAMP_WITH_TIMEZONE)?
I found a solution for LocalTime and LocalDateTime using ...
Carrol asked 23/3, 2015 at 13:14
3
Solved
If I do
import java.time.Instant;
...
Instant instant = Instant.parse("2018-01-02T18:14:59.000+01:00")
I get this exception:
Caused by: java.time.format.DateTimeParseException: Text '2018-06-...
4
Solved
I've just converted over many of my Dates to LocalDateTime per the new(ish) java 8 time package. I've enjoyed the switch so far until I started trying to serialize and deserialize.
How can I confi...
5
Solved
Given a FileTime fileTime, how can it be formatted in a custom way to a string?
String s = fileTime.toString() provides it in ISO format only.
String s = DateTimeFormatter.ofPattern("uuuu-MMM-dd ...
Lazurite asked 30/10, 2015 at 0:39
1
Solved
I am pretty new to Java 8 time, so this question probably has an obvious answer but after reading the other similar SO questions I couldn't spot any similarities which cause my issue.
Here's...
2
Solved
I have the following class that I want to store in MongoDB using Spring Data
@Document()
public class Tuple2<T extends Enum<T>> {
@Id
private String id;
@Indexed
@DateTimeFormat(iso ...
Clingy asked 23/11, 2014 at 16:38
0
I am unable to get the microseconds using java.time.Instant (Instant.now()) from android.
I am getting the date time without microseconds like 2020-04-10T12:43:40.442Z from android
But when I...
Campanula asked 10/4, 2020 at 12:53
© 2022 - 2024 — McMap. All rights reserved.