在java中获取最大日期值的最佳方式? [英] Best way to get maximum Date value in java?
本文介绍了在java中获取最大日期值的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
尝试
新日期(Long.MAX_VALUE)
它应该给你Java中最长的日期值。
I'm writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special cases for a null date throughout the code, I want to just convert null into the maximum possible Date. I don't see any obvious ways to get such a value without hard coding it. What's the best way to get the maximum value of whatever Date implementation is being used?
解决方案
Try
new Date(Long.MAX_VALUE)
which should give you the longest possible date value in Java.
这篇关于在java中获取最大日期值的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文