Scala笔记
1.四种操作符的区别和联系
- :: 该方法成为cons,表时构造,向队列头部加入元素。x::list表示向list头部加入元素。(列表构造:
12::1::2::"bar"::"foo" 表示List[Any]= (2,1,2,bar,foo)
- :+和+:表示分别在尾部加入元素和在头部加入元素。
- ++ 表示连接两个集合
- ::: 该方法只能用于连接两个list类型的集合
2.日期操作(经常用到,所以记录下)
- 获取今天0点时间戳
12val dateFormat = new SimpleDateFormat("yyyy-MM-dd")val cur = dateFormat.parse(dateFormat.format(new Date())).getTime
- 日期格式转时间戳
123val dateFormat = new SimpleDateFormat("yyyy-MM-dd")//val dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:MM:ss")val timestamp = dateFormat.parse(dateFormat.format(new Date())).getTime
- 时间戳转日期
12val dateFormat = new SimpleDateFormat("yyyy-MM-dd")val date = dateFormat.format(new Date())
3.删除目录或文件
本文参与
腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-09-23,如有侵权请联系
cloudcommunity@tencent.com 删除