transToString(time:Long):String{ return SimpleDateFormat("YY-MM-DD-hh-mm-ss").format(time) } /** * String to Timestamp * @param String * @return Timestamp */ fun transToTimeStamp(date:String):Long{ return SimpleDateFormat("YY-MM-DD-hh-mm-ss").parse(date, ParsePosition(0))....
Example 1: Convert String to Date using predefined formatters import java.time.LocalDate import java.time.format.DateTimeFormatter fun main(args: Array<String>) { // Format y-M-d or yyyy-MM-d val string = "2017-07-25" val date = LocalDate.parse(string, DateTimeFormatter.ISO_DATE) ...
//string to date convert @RequiresApi(Build.VERSION_CODES.O) fun convertStringDate(dateString: String): LocalDate { val format = DateTimeFormatter.ISO_DATE val tmpDate = LocalDate.parse("2019-12-10", format) var parsedDate: LocalDate = tmpDate try { parsedDate = LocalDate.parse(dateString,...
data class Order(var OrderID: Int,var Client: String,var SellerId: Int, var Amount: Double, var OrderDate: Date) var Orders=ArrayList<Order>() var sdf = SimpleDateFormat("yyyy-MM-dd") var raw=File("d:\\threelines.txt").readLines() raw.forEachIndexed{index,it-> if(index % 3==...
Log.e(TAG, "Time1 = " + dateFormat.format(System.currentTimeMillis())) //主线程中的代码会立即执行 runBlocking { // 但是这个表达式阻塞了主线程 delay(2000L) // ……堵塞2秒 Log.e(TAG, "主线程id = " + mainLooper.thread.id)
dateFormat S section 毫秒值转换为时分秒算法 计算: 0, 2s 格式化: 2s, 1s 序列图 下面是一个使用mermaid语法绘制的序列图,表示毫秒值转换为具体的时分秒算法的调用过程。 应用程序用户应用程序用户输入毫秒值转换为时分秒格式返回结果 在上面的序列图中,用户向应用程序输入一个毫秒值,应用程序将其转换为具体的时...
fun main(args: Array<String>) = runBlocking<Unit> { // 主协程 println("${format(Date())}: T0") // 启动主协程 launch(CommonPool) { //在common thread pool中创建协程 println("${format(Date())}: T1") delay(3000L) println("${format(Date())}: T2 Hello,") ...
funmain(args:Array<String>){println("Hello, world!")println(SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date()))println(helloKotlin())}funhelloKotlin():String{val words=mutableListOf<String>()words.add("Hello")words.add("Kotlin!")words.add(java.util.Date().toString())returnwords....
LocalDateAdapter()).create()Kotlin中则区分Kotlin和Java类,并做了语法规范:val kotlinClass : KClass<LocalDate> = LocalDate::classval javaClass : Class<LocalDate> = LocalDate::class.java所以在Kotlin,你不得不写成:val gson = GsonBuilder().registerTypeAdapter(LocalDate::class.java, LocalDate...
android.applicationVariants.all { variant -> def buildType = variant.buildType.name def createTime = new Date().format("YYYY_MM_dd_HH_mm", TimeZone.getTimeZone("GMT+08:00")) def fileName variant.outputs.each { if (buildType == "release") { fileName = "DSL_V${defaultConfig.version...