Special use JAVA string, a collection of time-related api

A. Collection

1. list conversion string (specified delimiter splicing): StringUtils.join (arrayList.toArray (), ",");

2. list of qualified delete elements: list.removeIf     
                                            Example: list.removeIf (s -> s% 2 == 0) delete the element being divisible by 2

3.map order specified set of key-value pairs: LinkedHashMap

 

II. String

1. whether the specified string for suffix End: endWith ();

III. Processing time

1. The maximum number of days of the month:

                                Calendar calendar = Calendar.getInstance();
                                calendar.set(Calendar.DATE, 1);// 当月首日
                                calendar.roll(Calendar.DATE, -1);// 当月最后日
                                Integer maxDate = calendar.get(Calendar.DATE);

2.Timestamp acquisition date (string): timestamp.toString () substring (0, 10);.

3. Compare whether two date / Calendar on the same day: DateUtils.isSameDay (date1, date2);

4.Timestamp解析string时间 : Timestamp timestamp = Timestamp.valueOf("");

Published 25 original articles · won praise 10 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_37794901/article/details/104058910