In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to get the month within a time interval by list". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to get the month within a time interval" together.
Dependence:
Joda-time joda-time 2.10.5import org.joda.time.DateTime;import java.util.ArrayList;import java.util.List;public class Client {public static void main (String [] args) {Long startTime = 1599148799000L; Long endTime=1599148799000L; DateTime start = new DateTime (startTime); DateTime end = new DateTime (endTime); int oneYear = start.getYear (); int oneMonth = start.getMonthOfYear () Int twoYear = end.getYear (); int twoMonth = end.getMonthOfYear (); List yearMonth = getYearMonth (oneYear,twoYear,oneMonth,twoMonth); System.out.println (yearMonth);} private static List getYearMonth (int oneYear,int twoYear, int oneMonth,int twoMonth) {return getYearMonth (oneYear,twoYear,oneMonth,twoMonth, "-") } private static List getYearMonth (int oneYear,int twoYear, int oneMonth,int twoMonth,String separator) {List yearMonth = new ArrayList (); if (oneYear < twoYear) {if (oneYear + 1 = = twoYear) {/ / two years are relational yearMonth.addAll (getYearMonth (oneYear,separator,oneMonth,12)); yearMonth.addAll (getYearMonth (twoYear,separator,1,twoMonth)) Return yearMonth;} else {while (oneYear < twoYear) {yearMonth.addAll (getYearMonth (oneYear,separator,1,12)); oneYear + = 1;} yearMonth.addAll (getYearMonth (twoYear,separator,1,twoMonth)) }} else {yearMonth.addAll (getYearMonth (twoYear,separator,oneMonth,twoMonth));} return yearMonth;} private static List getYearMonth (int year,String separator, int fromMonth,int toMonth) {List yearMonth = new ArrayList (); for (int I = fromMonth; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.