group存数据
public String[] matches(String regex)判断字符串是否满足正则表达式的规则
public String replaceAll(String regex,String newStr)按照正则表达式的规则进行替换
public String[] split(String regex)按照正则表达式的规则切割字符串
通常是创建网页对象,然后保证网络通畅,获取网页里的内容,创建正则表达式匹配截取打印
贪婪爬取:尽可能多的获取数据,Java默认是贪婪爬取
非贪婪爬取:尽可能少的获取数据,在数量词+*后面加问好就是非贪婪爬取
分组:分组就是一个小括号
捕获分组:后续还要继续使用
\\组号,表示把第X组的内容再出来用一次(内部使用)
$1,表示第一组的内容(外部使用)
非捕获分组:分组之后不需要再用本组数据,仅仅是把数据括起来
(?:正则)获取所有
(?=正则)获取前面部分
(?!正则)获取不是指定内容的前面部分
格林尼治时间/格林威治时间简称GMT
原子钟,利用铯原子的震动的频率计算出来的时间,作为世界标准时间UTC
JDK7前时间相关类
Date时间,Java写好的JavaBean类
精确到毫秒,利用空参构造创建的对象,默认表示系统当前时间。利用有参构造创建的对象,表示指定的时间。
创建日期对象:Date date = new Date(); Date date = new Date(指定毫秒值);
修改时间对象中的毫秒值:setTime(毫秒值);
获取时间对象中的毫秒值:getTime();
SimpleDateFormat格式化时间,把字符串表示的时间编程Date对象
public SimpleDateFormat()构造一个SimpleDateFormat,使用默认格式
public SimpleDateFormat(String pattern)构造一个SimpleDateFormat,使用指定格式
public final String format(Date date)格式化(日期对象->字符串)
public Date parse(String source)解析(字符串->日期对象)
Calendar日历
代表了系统当前时间的日历对象,可以单独修改,获取时间中的年月日
它是一个抽象类,不能直接创建对象
通过getInstance方法获取对象
setxxx修改
getxxx获取
add增加或者减少
日历类中月份的范围0~11
JDK8时间日期对象不可变
Date类:ZoneId时区,Instant时间戳,ZoneDateTime带时区的时间
static Set<String> getAvailableZoneIds()获取Java中支持的所有时区
static ZoneId systemDefault()获取系统默认时区
static ZoneId of(String zoneId)获取指定时区
static Instant now()获取当前时间的Instant对象(标准时间)
static Instant ofXxxx(long epochMilli)根据(秒/毫秒/纳秒)获取Instant对象
ZonedDateTime atZone(ZoneId zone) 指定时区
boolean isXxx(Instant otherInstant) 判断系列的方法
Instant minusXxx(long millisToSubtract) 减少时间系列的方法
Instant plusXxx(long millisToSubtract) 增加时间系列的方法
static ZonedDateTime now()获取当前时间的ZonedDateTime对象
static ZonedDateTime ofXxxx(。。。) 获取指定时间的ZonedDateTime对象
ZonedDateTime withXxx(时间) 修改时间系列的方法
ZonedDateTime minusXxx(时间) 减少时间系列的方法
ZonedDateTime plusXxx(时间) 增加时间系列的方法
日期格式化类SimpleDateFormat: DateTimeFormatter用于时间的格式化和解析
static DateTimeFormatter ofPattern(格式) 获取格式对象
String format(时间对象) 按照指定方式格式化
日历类Calendar:LocalDate:年、月、日, LocalTime:时、分、秒, LocalDateTime:年、月、日,时、分、秒
static XXX now() 获取当前时间的对象
static XXX of(。。) 获取指定时间的对象
get开头的方法 获取日历中的年、月、日、时、分、秒等信息
isBefore,isAfter 比较两个LocalDate
with开头的 修改时间系列的方法
minus开头的 减少时间系列的方法
plus开头的 增加时间系列的方法
工具类: Duration:时间间隔(秒,纳秒), Period:时间间隔(年,月,日), ChronoUnit:时间间隔
包装类
基本数据类型对应的引用类型,用一个对象把基本数据类型包装起来
public Integer(int value) 根据传递的整数创建一个Integer对象
public Integer(String s) 根据传递的字符串创建一个Integer对象
public static Integer valueOf(int i) 根据传递的整数创建一个Integer对象
public static Integer valueOf(String s)根据传递的字符串创建一个Integer对象
public static Integer valueOf(String s, int radix)根据传递的字符串和进制创建一个Integer对象
会优化-128~127之间的数,不会创建新对象直接返回已经创建好的
自动装箱把基本数据类型变成对应包装类,自动拆箱把包装类自动变成基本数据类型
获取包装类对象,不需要new,不需要调用方法,直接赋值