Date – how do I get the start and end times of a period?

I have an enumeration timeframe with values such as yesterday, lastweek, nextmonth, etc

I'm trying to write a method to receive timeframe and return the start and end dates of the period

I looked at the new Java 8 period class, which can take up the start time and end time, but there seems to be no clean way to retrieve these values

How to return the start and end dates immediately without using list (which looks like a wrong data structure) or some ugly date time algorithm?

Solution

No, the period does not record the start / end – it just represents the amount of time between them, in the calendar sense (not the "exact amount of time" represented by duration)

It sounds like you should basically create your own class, which has a start date and an end date You can still use period to implement it, but you have GetStartDate () and getenddate () to return the value of localdate You don't need to do any heavy date / time algorithms yourself – just calculate the start date, add the appropriate period or end date, and subtract the appropriate period according to the time range

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>