java-time Questions

7

Solved

I was playing with the new date time API but when running this: public class Test { public static void main(String[] args){ String dateFormatted = LocalDate.now() .format(DateTimeFormatter .o...
Forepleasure asked 14/4, 2014 at 20:8

6

Solved

I'm getting date data from weather API in two versions. The first one is just string like this: 2019-08-07 09:00:00 and like this: 1565209665. How do I change it to just the name of the day or day ...
Pronator asked 7/8, 2019 at 20:41

3

Solved

When I do this String datum = "20130419233512"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss").withZone(ZoneId.of("Europe/Berlin")); OffsetDateTime datetime = OffsetDa...
Dermatome asked 9/2, 2016 at 17:21

4

Solved

I'm new to java.time package. I have a LocalDate 2015-12-10. I need to convert this to ZonedDateTime. Time should be 00:00:00 and Zone is ZoneOffset.UTC. After conversion, ZonedDateTime should be...
Crawly asked 14/8, 2015 at 3:14

3

Solved

I have Java 8 Spring web app that will support multiple regions. I need to make calendar events for a customer location. So let's say my web and Postgres server is hosted in MST timezone (but I gue...
Ypsilanti asked 5/4, 2016 at 4:46

4

Solved

How to convert LocalDateTime to java.sql.Date in java-8? My search on internet mostly give me Timestamp related code or LocalDate to java.sql.Date. I'm looking for LocalDateTime to java.sql.Date. ...
Ritornello asked 14/7, 2017 at 12:10

8

Solved

I want convert string datetime to formatted string. e.g "2018-12-14T09:55:00" to "14.12.2018 09:55" as String => Textview.text how can I do this with kotlin or java for android ?
Abroms asked 14/12, 2018 at 13:58

2

Solved

I want to increase the millisecond value with LocalDateTime. I used plusNanos because I didn't have plusmillisecond. I wonder if this is the right way. I'm using JDK 1.8. I also want to know if the...
Alphabetical asked 28/3, 2023 at 12:50

2

Solved

We have the DayOfWeek enum defining the days of the week in standard ISO 8601 order. I want a List of those objects in the order appropriate to a Locale. We can easily determine the first day of...
Tavish asked 20/5, 2019 at 3:4

4

I have code that looks like this: String PROPER_DATE_FORMAT = "yyyy-MM-dd"; String format = "yyyy-MM-dd'T'HH:mm:ss.SSSX"; SimpleDateFormat sdf = new SimpleDateFormat(format); Date d = sdf.parse(I...
Clemenciaclemency asked 25/5, 2018 at 19:52

1

Solved

I am having trouble with converting old dates from java.time.LocalDateTime to java.util.Date I tried a lot of variation and it still has the same shifted dates. I would assume that it is some weird...
Antitrades asked 27/1, 2023 at 5:20

3

Solved

Why does the following fail to run, with the date-time string unable to parse as an OffsetDateTime? String inputOdt = "2016-01-23T12:34:56 GMT+8"; DateTimeFormatter formatterOdt = DateTimeFormatte...
Steinberg asked 17/5, 2016 at 22:16

3

Solved

I work with the new DateTime API of Java 8. How to convert a LocalDate to an Instant? I get an exception with LocalDate date = LocalDate.of(2012, 2, 2); Instant instant = Instant.from(date); an...
Bullate asked 22/4, 2014 at 9:15

4

DateTimeFormmater doesn't seem to handle single digit day of the month: String format = "MM/dd/yyyy"; String date = "5/3/1969"; System.out.println(new SimpleDateFormat(format).parse(date)); System...
Sonja asked 19/12, 2014 at 17:54

5

Solved

I get the datetime value as created_at '2012-02-22T02:06:58.147Z' Read-only. The time at which this task was created. Which is given by Asana API I am using Java 8 to parse the date time as fo...
Boettcher asked 9/3, 2016 at 2:13

4

Solved

The DateTimeFormatter class documentation says about its formatting codes for the year: u year year 2004; 04 y year-of-era year 2004; 04 … Year: The count of letters determines the minimum field w...
Flurry asked 16/12, 2016 at 4:48

7

Solved

How do I extract the epoch value to Long from instances of LocalDateTime or LocalDate? I've tried the following, but it gives me other results: LocalDateTime time = LocalDateTime.parse("04.02.201...
Frisket asked 10/4, 2014 at 13:52

9

Solved

Right now I am using this code Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Ca...
Singlehanded asked 9/6, 2010 at 13:21

3

Solved

I tried like below, but in both cases, it is showing the same time. What am I doing wrong? LocalDateTime currentTime = LocalDateTime.now(ZoneId.of("UTC")); Instant instant = currentTime.t...
Hibernal asked 23/6, 2015 at 13:4

4

Solved

I will be asking a user to enter a specific time: 10AM, 12:30PM, 2:47PM, 1:09AM, 5PM, etc. I will be using a Scanner to get the user's input. How can I parse/convert that String to a LocalTime ob...
Williamwilliams asked 9/8, 2017 at 15:41

6

Solved

Here is my method to parse String into LocalDateTime. public static String formatDate(final String date) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"); L...

4

Solved

Is there a way how to create JSR-310 formatter that is able to parse both following date/times with variable length of seconds fraction? 2015-05-07 13:20:22.276052 or 2015-05-07 13:20:22.276 ...
Fibroblast asked 7/5, 2015 at 13:52

3

Solved

I have the this simple code: DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss.SSSSSS Z"); LocalDateTime.now().format(FORMATTER) Then I will get following exception: ...
Krupp asked 29/8, 2014 at 3:42

3

Solved

Given an object of Instant, a time string representing the time at a specific ZoneId, How to construct a ZonedDateTime object with the date part (year, month, day) from the instant at the given Zon...
Brnaby asked 23/7, 2015 at 16:49

3

Solved

I want to convert a ZonedDateTime to a String in the format of ("dd/MM/yyyy - hh:mm"). I know this is possible in Joda-Time other types, just using their toString("dd/MM/yyyy - hh:mm...
Yesman asked 23/2, 2017 at 20:17

© 2022 - 2024 — McMap. All rights reserved.