Skip to content
Advertisement

Tag: datetime

Getting the UTC timestamp in Java

An old Stack Overflow posting suggests that the way to get the UTC timestamp in Java is the following: Unfortunately this does not work for me. I have a very simple program (reproduced below) which demonstrates different behavior. On Windows: the time is the local time and it is labeled with the offset with GMT On Linux: the time is

Java DateTimeFormatter parsing with special characters

I’m having some troubles getting my format right for using DataTimeFormatter to parse a date time String in the format of: I have a DateTimeFormatter pattern that works to produce this format, but it doesn’t work to parse the same String. That pattern is: If there are other libraries for DateTime parsing that are more appropriate for this type of

Date parsing in Java using SimpleDateFormat

I want to parse a date in this format: “Wed Aug 26 2020 11:26:46 GMT+0200” into a date. But I don’t know how to do it. I tried this: I am getting this error: Unparseable date: “Wed Aug 26 2020 11:26:46 GMT+0200”. Is my date format wrong? And if so could somebody please point me in the right direction? Answer

How to force LocalDateTime Month to be 3 letters long

My goal is to use LocalDateTime and display a month with exactly 3 letters. For the English language, this is easy: The result is as expected: For the German language (as above, only with Locale.GERMAN), the result is unexpected: While the abbreviations are all common in german, “März”, “Juni” and “Juli” haven’t been shortened (“Mai” doesn’t need to be shortened).

How to format the date time correctly in Spring Boot?

I would like to know how to format the date time correctly? The result is Localdatetime yyyy-MM-ddTHH:mm. Could you advise how to solve? I’m using Java 11, and does it because @JsonFormat not support @RequestParam? Controller: Entity: Answer Since you are using Spring-boot , I’m also assuming you are using java8 . In any case try using java8 time api

Does the JRE support posix TZ description rather than TZ name?

Java doesn’t appear to apply DST offset when the OS uses a POSIX time zone description rather than a time zone name. Is the use of a TZ description unsupported by the JRE or is this behavior a bug? More details… I’m working on a Linux (Debian) based system where the TZ environment variable is set to a POSIX formatted

Advertisement