Simple use of LocalData time and JSON string writing in Java

// Get the current month and convert it to type
 LocalDate startDate = LocalDate.parse(ltcCountDeviationVo.getEndDate(), DateTimeFormats.ofPattern("yyyy-MM-dd"));

 //Get the 26th of the previous month of this month
 LocalDate lastMonth = startDate.plusMonths(-1);
 LocalDate lastTwentySixDay = LocalDate.of(lastMonth.getYear(), lastMonth.getMonth(), 26);

 // Get the 25th of this month
 LocalDate thisTwentyFiveMonth = LocalDate.of(startDate.getYear(), startDate.getMonth(), 25);

====================================================================

String json = "{\"data1\":[{\"name\":\"aa\",\"age\":\"12\"},{\"name\":\"bb\",\"age\":\"13\"}],\"data2\":{\"nowpage\":1,\"pagesize\":2}}" ;

中\为转义字符。\"表示一个"的意思,所以上面的json确实是JSON格式的字符串

一、转义字符是一类特殊的字符:

1、展示无法’看见‘的字符

2、与语言本身语法有冲突的字符

\n   换行

\t    横向制表符

\'    单引号

\n 换行

\r 回车

>>> print('hello \n world')
hello 
 world
>>> print('hello \\n world')
hello \n world

 

Guess you like

Origin blog.csdn.net/qq_40390762/article/details/124792558