Wednesday, October 9, 2024

Re: java.time support

On the server, java.util.Date is unaffected as Jens pointed out - it is not backed by a 32-bit int, but a 64-bit int. Your swing and web implementations will be able to use java.util.Date beyond 2038:

Here's plain Java, using jshell to demonstrate that this will work with much larger dates than a decade away:

jshell> new java.util.Date(Long.MAX_VALUE)
$1 ==> Sun Aug 17 01:12:55 CST 292278994


As he also pointed out, you _can_ use java.time using the linked package, but the java.time APIs are not very conducive to emulation in the browser, so any emulation will always be a subset of the full possible functionality that a regular JVM has.
On Wednesday, October 9, 2024 at 10:08:42 AM UTC-5 blackh...@gmail.com wrote:
So web is not going to be worried, but... :) 
We have user interfaces for both thick (swing) and web using dates and now we need to use java.util.Date as this is supported by GWT.
Is there a way to use anything else than java.util.Date that is supported by GWT? 

Op wo 9 okt 2024 om 16:51 schreef Jens <jens.ne...@gmail.com>:
Here is a link about the year 2038 problem: https://en.wikipedia.org/wiki/Year_2038_problem

Ah ok, thats where you are coming from.

JavaScript/ECMAScript defines that JavaScript Date supports exactly 100000000 days before and after unix epoch. This gives us a maximum year of 275760 that JavaScript Date can currently represent.

Java itself uses a long to represent millis since epoch in java.util.Date. Because long is 64 bit the maximum year that java.util.Date can represent is 292278994.

JavaScript: 275760
Java: 292278994

Since GWT emulates java.util.Date using native JavaScript Date the max year in GWT code is the one of JavaScript.

In any case year 2038 shouldn't be a problem, thats why I asked. You can easily verify it in browser console using

var millis = Date.parse("2040-06-01");
var date = new Date(millis);
console.log(date);

-- J. 

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/f0487d21-3a72-46ed-81a4-a9e3b02e05fcn%40googlegroups.com.

No comments:

Post a Comment