GWT java.util.Date序列化 [英] GWT java.util.Date serialization

查看:137
本文介绍了GWT java.util.Date序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个基于GWT的Web应用程序,以自动化一些我们需要间隔的任务。有两个日期选择器在哪里选择开始日期和结束日期。我看到有一种算法将JavaScript日期转换为字符串以便根据http请求发送。
例如:

11-08-2015是 VDkLYWA



11-09-2015 VDpU $ GA



2015年10月10日 VDuej2A



我尝试在JS代码中挖掘,但是,正如您可能想象的那样,没有太多的运气。
我猜在GWT项目源代码中有一个非模糊化的反序列化版本>以便我可以对其进行反向工程,但我没有使用GWT的经验,也不知道在哪里寻找。
也许有人已经解决了这个问题,或者可以指向我一些资源?

谢谢!

解决方案

GWT有一个类 com.google.gwt.lang.LongLib (在gwt-dev.jar中),它将日期长整型值进行字符串转换。这个转换基本上是Base64转换。以下是它的工作原理:

  Date d = new Date(115,10,8,0,0,0) ; // 2015-11-08 00:00:00 
String s = LongLib.toBase64(d.getTime());
System.out.println(s); //打印VDjNlRA

因此,您可以将此jar包含在您的应用程序中以进行此转换,或者您可以在javascript中编写相同的算法。


I'm building a scraper a GWT based web app, to automatize some tasks we need to do on interval basis. There are two date pickers where to choose start date and end date. I see that there is an algorithm to convert Javascript dates to strings to send along the http request. For instance:

11-08-2015 is VDkLYWA

11-09-2015 is VDpU$GA

11-10-2015 is VDuej2A

I tried to dig in the JS code but, as you may imagine, with not much luck. I'm guessing there is an non-obfuscated version of the de-serialization in the GWT project source code so that I can reverse-engineer it, but I have no experience with GWT and don't know exactly where to look. Maybe someone has already solved this problem or can point me to some resources?

Thanks!

解决方案

GWT has a class com.google.gwt.lang.LongLib (inside gwt-dev.jar) which converts date long value to string conversion. This conversion is basically Base64 conversion. Below is a sample how it works:

Date d = new Date(115, 10, 8, 0, 0, 0); //2015-11-08 00:00:00
String s = LongLib.toBase64(d.getTime());
System.out.println(s); //Prints VDjNlRA

So, either you can include this jar in your application to do this conversion or you can write the same algorithm in javascript.

这篇关于GWT java.util.Date序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆