In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to achieve date operation in Scala. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
It is necessary to operate on the date when counting.
Get the date import java.text. {DecimalFormat, DecimalFormatSymbols, SimpleDateFormat} import java.util.Calendardef getPreviousdate (date: String, pre_cnt:Int): String = {var dateFormat:SimpleDateFormat = new SimpleDateFormat ("yyyyMMdd") var cal:Calendar = Calendar.getInstance () var dt:Date = dateFormat.parse (date) cal.setTime (dt) Cal.add (Calendar.DATE,-pre_cnt) var pre_date = dateFormat.format (cal.getTime ()) return pre_date} get the number of days between two dates def getDateDiff (date1: String) Date2: String: Int = {var dateFormat:SimpleDateFormat = new SimpleDateFormat ("yyyyMMdd") var cal_1:Calendar = Calendar.getInstance () var cal_2:Calendar = Calendar.getInstance () var dt_1:Date = dateFormat.parse (date1) var dt_2:Date = dateFormat.parse (date2) cal_1.setTime (dt_1) var time_1 = cal_1.getTimeInMillis () cal_2. SetTime (dt_2) var time_2 = cal_2.getTimeInMillis () var diff_days= (time_1-time_2) / (1000-3600-24) return diff_days.toInt.abs} this is the end of the article on "how Scala implements date manipulation" Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.