一:验证日期1:日期必须满足yyyy-MM-dd格式2:日期必须是合法的日期,如2016-02-30就是不存在1//验证就诊日期2function checkVisitDate(date){
3var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
4if(reg.test(date)){ //如果满足正则表达式,则判断是否是合法的日期5returnnew Date(date).getDate() == date.substring(date.length-2);
6 }
7returnfalse;
8 } 二:验证年龄1:年龄必须大于02:1到3位的数字1//验证年龄2f...
原文网址:http://www.cnblogs.com/freeabyss/archive/2013/05/15/3187057.html字符串查找String提供了两种查找字符串的方法,即indexOf与lastIndexOf方法。 1、indexOf(String s) 该方法用于返回参数字符串s在指定字符串中首次出现的索引位置,当调用字符串的indexOf()方法时,会从当前字符串的开始位置搜索s的位置;如果没有检索到字符串s,该方法返回-11 String str ="We are students";
2 int size = str.indexOf("a"); ...
一、js获取字符串的字节数这个好使---
function getBytesLength(str) {
// 在GBK编码里,除了ASCII字符,其它都占两个字符宽return str.replace(/[^\x00-\xff]/g, ‘xx‘).length;}用正则表达式检测所用的时间竟然是for循环的两倍!!!!var lenFor = function(str){var byteLen=0,len=str.length;if(str){for(var i=0; i<len; i++){if(str.charCodeAt(i)>255){byteLen += 2;}else{byteLen++;}}return byteLen;}else{return 0;}
}...
POI中常用设置EXCEL的操作小结:操作excel如下HSSFWorkbook wb = new HSSFWorkbook(); //创建一个webbook,对应一个Excel文件HSSFSheet sheet = wb.createSheet(); //添加一个sheet,对应Excel文件中的sheet 构造方法可以有参也可以无参wb.createSheet("学生表一")HSSFRow row = sheet.createRow((int) 0); //sheet的第一行HSSFCell cell = row.createCell(0); //某行的第一列 cell.setCellValue("学号"); //添...
1.创建队列
Queue<Integer> queue = new LinkedList<>();2.添加元素
//时间复杂度O(1)
queue.add(1);
queue.add(2);
queue.add(3);
//[1,2,3]3.获取即将出队的元素
//时间复杂度O(1)
//temp=1
int temp = queue.peek();4.删除即将出队的元素
//时间复杂度O(1)
//temp1=1
int temp1 = queue.poll();
//queue = [2,3]5.判断队列是否为空
//时间复杂度O(1)
// statue = false
Boolean statue = queue.isEmpty();6.队列长度
//时间复杂...
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;@Data
@AllArgsConstructor
@Builder
public class Fruit {private Integer id;private String name;private Double money;private Integer num;
}测试用例
import org.junit.Before;
import org.junit.Test;import java.util.*;
import java.util.stream.Collectors;public class FruitTest {List<Fruit> fruitList = null;@Beforepublic void setu...
1.获取当前日期@Testpublic void demo1(){//获取当前年月日LocalDate today = LocalDate.now();System.out.println("当前的日期年月日:" + today);//获取当前年月日时分秒LocalDateTime localDateTime = LocalDateTime.now();System.out.println("当前年月日时分秒:" + localDateTime);//获取当前年月YearMonth yearMonth = YearMonth.now();System.out.println("当前的日期年月:" + yearMonth);//获取当前月日MonthDay monthDay =...
目录
1.什么是流
2.构建流
2.1由值构建流
2.2由数组创建流
2.3由文件生成流
2.4由函数生成流:创建无限流
2.4.1迭代
2.4.2生成
3.流操作
3.1中间操作
3.2终端操作
3.3 实例
4.收集数据
4.1归约
4.1.1求和
4.1.2最大值:
4.1.3最小值:
4.2汇总
4.2.1常用汇总方法
4.2.2字符串连接1.什么是流
Java8对流的定义就是“从支持数据处理操作的源生成的元素序列”。
元素序列——就像集合一样,流也提供了一个接口,可以访问特定元素类型的一...
一、数组异常
1、 数组越界异常package day05;public class Demo01ArrayIndex {public static void main(String[] args) {int[] array = { 15, 25, 35 };System.out.println(array[0]); //15System.out.println(array[1]); // 25System.out.println(array[2]); // 35// 错误写法// 并不存在3号元素,所以发生异常System.out.println(array[3]);}
}
输出"C:\Program Files\Java\jdk-13.0.2\bin\java.exe" "-javaagent:C:\Program Fi...
前期准备:首先给hashMap里面put一些键值对,代码如下:
HashMap<Integer, Integer> hashMap = new HashMap<>();
hashMap.put(5, 2);
hashMap.put(9, 2);
hashMap.put(8, 1);
hashMap.put(7, 3);
hashMap.put(16, 1);
hashMap.put(10, 2);
hashMap.put(6, 2);
//其实下面两个键值对是没有存的
hashMap.put(5, 2);
hashMap.put(5, 3);
当...
public class ListNode {public int value;public ListNode next;public ListNode(int value) {this.value = value;}}public class Mylist {/*** 头结点插入*/public static void headInsert(ListNode head, ListNode newHead) {ListNode old = head;head = newHead;head.next = old;}/*** 尾节点插入*/public static void tailInsert(ListNode tail, ListNode newTail) {ListNode old = tail;tail = newTail;old.next = tail;newT...
1. ES查看索引
curl -X GET http://172.0.0.1:9200/_cat/indices?v
2. 列出每个 Index 所包含的类型
curl http://172.0.0.1:9200/_mapping?pretty=true
3. 新建索引
curl -X PUT "172.0.0.1:9200/testindex"
4. 删除索引
curl -X DELETE 172.0.0.1:9200/testindex
5. 往testindex的表person中加入一行测试数据
curl -H "Content-Type: application/json" -X PUT http://172.0.0.1:9200/testindex/person/1 -d ...
java.time包中的是类是不可变且线程安全的。
新的时间及日期API位于java.time中,下面是一些关键类
●Instant——它代表的是时间戳,注意这里默认的Instant是比北京少8个时区
●LocalDate——不包含具体时间的日期,比如2014-01-14。它可以用来存储生日,周年纪念日,入职日期等。
●LocalTime——它代表的是不含日期的时间
●LocalDateTime——它包含了日期及时间,不过还是没有偏移信息或者说时区。
●ZonedDateTime——这是一个...