常用Java时间处理、guava-Lists分割
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import java.util.List;
public static void main(String[] args) {
long diff = new Date().getTime();
long system = System.currentTimeMillis();
long nanoTime = System.nanoTime();
System.out.println("system :" + system);
System.out.println("diff :" + diff);
System.out.println("nanoTime:" + nanoTime);
// google guava-16.0.1.jar
List countUp = Ints.asList(1, 2, 3, 4, 5,6);
// [5, 4, 3, 2, 1]
List countDown = Lists.reverse(countUp);
System.out.println("countDown:"+JSON.toJSONString(countDown));
//[[1,2],[3,4],[5,6]]
List<List<Integer>> parts = Lists.partition(countUp, 2);
for(List<Integer> subList:parts){
System.out.println(parts.size()+",subList"+JSON.toJSONString(subList));
}
System.out.println("parts :"+JSON.toJSONString(parts));
}
最后console输出:
system :1510045212131
diff :1510045212131
nanoTime:26242702289112
countDown:[6,5,4,3,2,1]
3,subList[1,2]
3,subList[3,4]
3,subList[5,6]
parts :[[1,2],[3,4],[5,6]]
本文共计 1537 字,感谢您的耐心浏览与评论。
0条回应:“常用Java时间处理、guava-Lists分割”