日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

scala 随机生成整数_如何在Scala中以整数形式获取当前年份?

發布時間:2023/12/1 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 scala 随机生成整数_如何在Scala中以整数形式获取当前年份? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

scala 隨機生成整數

In Scala programming language, there is an option for the programmer to use libraries of java because of its interoperability with java.

在Scala編程語言中,程序員可以選擇使用Java庫,因為它可以與Java互操作。

There are a few methods to extract the date of a program,

有幾種方法可以提取程序的日期 ,

1)Java 8年 (1) Java 8 Year)

The java.time.year library is used to get the value of the current year.

java.time.year庫用于獲取當前年份的值 。

Syntax:

句法:

val data_int = Year.now.getvalue

Program:

程序:

import java.time.Yearobject MyClass {def main(args: Array[String]) {val year: Int = Year.now.getValue; printf(" "+year)} }

Output

輸出量

2019

2)Java 8 localDate (2) Java 8 localDate )

The java.time.localDate library is used to get the current date and we can extract year also using its method.

java.time.localDate庫用于獲取當前日期 ,我們也可以使用其方法提取年份 。

Synatx:

Synatx:

val data_int = LocalDate.now.getvalue

Example:

例:

import java.time.LocalDateobject MyClass {def main(args: Array[String]) {val year: Int = LocalDate.now.getYear; printf(" "+year)} }

Output

輸出量

2019

3)Java日歷 (3) Java Calendar)

The java.util.calendar is used to to get calendar information using the getInstance method. And passing the Calendar.YEAR to it will return the value of Year.

java.util.calendar用于使用getInstance方法獲取日歷信息 。 并將Calendar.YEAR傳遞給它將返回Year的值。

Synatx:

Synatx:

val year = Calendar.getInstance.get(Calendar.YEAR)

Example:

例:

import java.util.Calendarobject MyClass {def main(args: Array[String]) {val year: Int = Calendar.getInstance.get(Calendar.YEAR); printf(" "+year)} }

Output

輸出量

2019

翻譯自: https://www.includehelp.com/scala/how-to-get-the-current-year-as-an-integer-in-scala.aspx

scala 隨機生成整數

總結

以上是生活随笔為你收集整理的scala 随机生成整数_如何在Scala中以整数形式获取当前年份?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。