假期 - 有没有java实现? [英] Holidays - is there a java implementation?

查看:126
本文介绍了假期 - 有没有java实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个jar文件可以执行以下操作:

I'd like to know if there is a jar-file out there that could do the following:

DateMidnight dateInQuestion = new DateMidnight(12,12,2000);
DateChecker.isNationalHoliday(dateInQuestion, Locale.ITALY);

如果没有,为什么?当然,在99%的时间里,假期有很多适当的规则。

If there isn't, why? Surely there are lots of properly based rules for the holidays in 99% of the times.

现在我们在数据库中注明表格,国家+我们当涉及到每年不在同一个日子的假期时,有一些实施。我们必须为每个新的国家/地区新增客户增加我们的实施。

Right now we're mainting a table in our database, with the countries + we have some implementation when it comes to holidays that aren't on the same date every year. We have to add to our implementation for every new country we get new customers.

我们可以这么简单吗?

(如果java领域没有这样的东西,可以从其他语言中移植吗?)

(If there is no such thing in the java sphere, can I port it from some other language?)

推荐答案

据我所知,Java中没有任何可靠的存在。这也是有道理的,这种信息对变化非常敏感。对其进行硬编码会使您的代码在每次Java更新时都可能发生突破,从而导致大量的维护和兼容性问题。目前,在Java SE中,时区已被硬编码/维护,甚至单独已经导致许多错误

Nothing robust exist in Java as far as I know. It also makes sense, this kind of information is namely extremely sensitive to changes. Hardcoding it would make your code potentially break on every Java update which may lead to lot of maintenance and compatibility troubles. Currently at hightest the timezones are hardcoded/maintained in Java SE and even alone that has already lead to many bugs.

而是使用公共Web服务。例如。 http://www.bank-holidays.com

Rather use a public webservice for that. E.g. http://www.bank-holidays.com


本网站通知您银行(以及若干国家的证券交易所和学校假期)由于宗教或公共活动而关闭的所有日子。

This site informs you of all the days when banks (as well as stock exchange & school holidays in a number of countries) are closed due to religious or public events. Major events (elections, announced strikes, trade fairs, festivals, sports events...) are also listed.

我们的免费服务允许您查看当前日历年(选举,宣布罢工,展览会,节日,体育赛事...)只读)。
对于2欧元/国家/年,我们的PAY SERVICE(点击信用卡图标)可以访问2000-2070年的日历年。

Our FREE SERVICE allows you to view the current calendar year (view only). For 2 euros/country/year, our PAY SERVICE (click on credit card icon) gives you access to calendar years 2000-2070.

然后写一个Java包装器。或者查找现有的Java API,而这些API又由webservice支持。

And write a Java wrapper around that. Or look for existing Java API's which are in turn already backed by a webservice.

这篇关于假期 - 有没有java实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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