当前位置: 首页 > news >正文

网站建设续约合同门户网站的首页模板

网站建设续约合同,门户网站的首页模板,wordpress jexus,微站网日期与时间 Date /*** 使用Date类处理时间#xff0c;获取时间信息*/ public class Test {public static void main(String[] args) {//创建一个Data类的对象#xff0c;代表此刻系统日期时间对象Date d new Date();System.out.println(d);//获取时间毫秒值long time d.ge…日期与时间 Date /*** 使用Date类处理时间获取时间信息*/ public class Test {public static void main(String[] args) {//创建一个Data类的对象代表此刻系统日期时间对象Date d new Date();System.out.println(d);//获取时间毫秒值long time d.getTime();System.out.println(time);long time1 System.currentTimeMillis();System.out.println(time1);} } 案例  public class Test {public static void main(String[] args) {// 得到当前时间毫秒值Date d1 new Date();System.out.println(d1);// 当前时间往后走 1小时 121秒long time System.currentTimeMillis();time (60 * 60 121) * 1000;// 把时间毫秒值转换成对应日期对象Date d2 new Date(time); // Date d2 new Date(); // d2.setTime(time);System.out.println(d2);} } SimpleDateFormat 介绍 public class Test {public static void main(String[] args) {// 日期对象Date d new Date();System.out.println(d);// 格式化日期对象SimpleDateFormat sdf new SimpleDateFormat(yyyy年MM月dd日 HH:mm:ss EEE a);// 开始格式化日期对象成为字符串形式String rs sdf.format(d);System.out.println(rs);// 格式化时间毫秒值//问121秒后的时间是多少long time System.currentTimeMillis() 121 * 1000;String rs2 sdf.format(time);System.out.println(rs2);} } public class Test {public static void main(String[] args) throws ParseException {//字符串时间拿到程序中来String dateStr 2021年08月06日 11:11:11;//把字符串时间解析成日期对象 形式必须与被解析时间形式完全一样否侧运行时会报错SimpleDateFormat sdf new SimpleDateFormat(yyyy年MM月dd日 HH:mm:ss);Date d sdf.parse(dateStr);//往后走的时间long time d.getTime() (2L*24*60*60 14*60*60 49*60 6) * 1000;//格式化时间毫秒值就是结果System.out.println(sdf.format(time));} } 总结 练习 public class Test {public static void main(String[] args) throws ParseException {// 记录开始和结束时间String startTime 2021-11-11 00:00:00;String endTime 2021-11-11 00:10:00;// 小贾和小皮String xiaoJia 2021-11-11 00:03:47;String xiaoPi 2021-11-11 00:10:11;// 解析他们的时间SimpleDateFormat sdf new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);Date d1 sdf.parse(startTime);Date d2 sdf.parse(endTime);Date d3 sdf.parse(xiaoJia);Date d4 sdf.parse(xiaoPi);if (d3.after(d1) d3.before(d2)) {System.out.println(小贾秒杀成功);} else {System.out.println(小贾秒杀失败);}if (d4.after(d1) d4.before(d2)) {System.out.println(小皮秒杀成功);} else {System.out.println(小皮秒杀失败);}} } Calendar 介绍 public class Test {public static void main(String[] args) {// 拿到系统此刻日历对象Calendar cal Calendar.getInstance();// 获取日历信息int year cal.get(Calendar.YEAR);System.out.println(year);int month cal.get(Calendar.MONTH) 1;System.out.println(year);int day cal.get(Calendar.DAY_OF_YEAR);System.out.println(year);// 修改日历的某个字段信息cal.set(Calendar.HOUR,12);System.out.println(cal);// 拿到此刻日期对象Date d cal.getTime();System.out.println(d);// 拿到此刻时间毫秒值long time cal.getTimeInMillis();System.out.println(time);} } JDK8新增日期类 概述 LocalTime /LocalDate LocalDateTime public class Demo01LocalDate {public static void main(String[] args) {// 1、获取本地日期对象。LocalDate nowDate LocalDate.now();System.out.println(今天的日期 nowDate);//今天的日期int year nowDate.getYear();System.out.println(year year);int month nowDate.getMonthValue();System.out.println(month month);int day nowDate.getDayOfMonth();System.out.println(day day);//当年的第几天int dayOfYear nowDate.getDayOfYear();System.out.println(dayOfYear dayOfYear);//星期System.out.println(nowDate.getDayOfWeek());System.out.println(nowDate.getDayOfWeek().getValue());//月份System.out.println(nowDate.getMonth());//AUGUSTSystem.out.println(nowDate.getMonth().getValue());//8System.out.println(------------------------);LocalDate bt LocalDate.of(1991, 11, 11);System.out.println(bt);//直接传入对应的年月日System.out.println(LocalDate.of(1991, Month.NOVEMBER, 11));//相对上面只是把月换成了枚举} }public class Demo02LocalTime {public static void main(String[] args) {// 1、获取本地时间对象。LocalTime nowTime LocalTime.now();System.out.println(今天的时间 nowTime);//今天的时间int hour nowTime.getHour();//时System.out.println(hour hour);//hourint minute nowTime.getMinute();//分System.out.println(minute minute);//minuteint second nowTime.getSecond();//秒System.out.println(second second);//secondint nano nowTime.getNano();//纳秒System.out.println(nano nano);//nanoSystem.out.println(-----);System.out.println(LocalTime.of(8, 20));//时分System.out.println(LocalTime.of(8, 20, 30));//时分秒System.out.println(LocalTime.of(8, 20, 30, 150));//时分秒纳秒LocalTime mTime LocalTime.of(8, 20, 30, 150);System.out.println(---------------);System.out.println(LocalDateTime.of(1991, 11, 11, 8, 20));System.out.println(LocalDateTime.of(1991, Month.NOVEMBER, 11, 8, 20));System.out.println(LocalDateTime.of(1991, 11, 11, 8, 20, 30));System.out.println(LocalDateTime.of(1991, Month.NOVEMBER, 11, 8, 20, 30));System.out.println(LocalDateTime.of(1991, 11, 11, 8, 20, 30, 150));System.out.println(LocalDateTime.of(1991, Month.NOVEMBER, 11, 8, 20, 30, 150));} }public class Demo03LocalDateTime {public static void main(String[] args) {// 日期 时间LocalDateTime nowDateTime LocalDateTime.now();System.out.println(今天是 nowDateTime);//今天是System.out.println(nowDateTime.getYear());//年System.out.println(nowDateTime.getMonthValue());//月System.out.println(nowDateTime.getDayOfMonth());//日System.out.println(nowDateTime.getHour());//时System.out.println(nowDateTime.getMinute());//分System.out.println(nowDateTime.getSecond());//秒System.out.println(nowDateTime.getNano());//纳秒//日当年的第几天System.out.println(dayOfYear nowDateTime.getDayOfYear());//dayOfYear249//星期System.out.println(nowDateTime.getDayOfWeek());//THURSDAYSystem.out.println(nowDateTime.getDayOfWeek().getValue());//4//月份System.out.println(nowDateTime.getMonth());//SEPTEMBERSystem.out.println(nowDateTime.getMonth().getValue());//9LocalDate ld nowDateTime.toLocalDate();System.out.println(ld);LocalTime lt nowDateTime.toLocalTime();System.out.println(lt.getHour());System.out.println(lt.getMinute());System.out.println(lt.getSecond());} }public class Demo04UpdateTime {public static void main(String[] args) {LocalTime nowTime LocalTime.now();System.out.println(nowTime);//当前时间System.out.println(nowTime.minusHours(1));//一小时前System.out.println(nowTime.minusMinutes(1));//一分钟前System.out.println(nowTime.minusSeconds(1));//一秒前System.out.println(nowTime.minusNanos(1));//一纳秒前System.out.println(----------------);System.out.println(nowTime.plusHours(1));//一小时后System.out.println(nowTime.plusMinutes(1));//一分钟后System.out.println(nowTime.plusSeconds(1));//一秒后System.out.println(nowTime.plusNanos(1));//一纳秒后System.out.println(------------------);// 不可变对象每次修改产生新对象System.out.println(nowTime);System.out.println(---------------);LocalDate myDate LocalDate.of(2018, 9, 5);LocalDate nowDate LocalDate.now();System.out.println(今天是2018-09-06吗 nowDate.equals(myDate));//今天是2018-09-06吗 falseSystem.out.println(myDate 是否在 nowDate 之前 myDate.isBefore(nowDate));//2018-09-05是否在2018-09-06之前 trueSystem.out.println(myDate 是否在 nowDate 之后 myDate.isAfter(nowDate));//2018-09-05是否在2018-09-06之后 falseSystem.out.println(---------------------------);// 判断今天是否是你的生日LocalDate birDate LocalDate.of(1996, 8, 5);LocalDate nowDate1 LocalDate.now();MonthDay birMd MonthDay.of(birDate.getMonthValue(), birDate.getDayOfMonth());MonthDay nowMd MonthDay.from(nowDate1);System.out.println(今天是你的生日吗 birMd.equals(nowMd));//今天是你的生日吗 false} }Instant public class Test {public static void main(String[] args) {// 得到一个Instant时间戳对象Instant instant Instant.now();System.out.println(instant);// 获取此刻的时间戳Instant instant1 Instant.now();System.out.println(instant1.atZone(ZoneId.systemDefault()));// 如何返回Date对象Date date Date.from(instant);System.out.println(date);Instant i2 date.toInstant();System.out.println(i2);} } DateTimeFormatter public class Demo06DateTimeFormat {public static void main(String[] args) {// 本地此刻 日期时间 对象LocalDateTime ldt LocalDateTime.now();System.out.println(ldt);// 解析/格式化器DateTimeFormatter dtf DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss EEE a);// 正向格式化System.out.println(dtf.format(ldt));// 逆向格式化System.out.println(ldt.format(dtf));// 解析字符串时间DateTimeFormatter dtf1 DateTimeFormatter.ofPattern(yyyy-MM-dd HH:mm:ss);// 解析当前字符串时间成为本地日期时间对象LocalDateTime ldt1 LocalDateTime.parse(2019-11-11 11:11:11 , dtf1);System.out.println(ldt1);System.out.println(ldt1.getDayOfYear());} } Duration /Period public class Demo07Period {public static void main(String[] args) {// 当前本地 年月日LocalDate today LocalDate.now();System.out.println(today);//// 生日的 年月日LocalDate birthDate LocalDate.of(1998, 10, 13);System.out.println(birthDate);Period period Period.between(birthDate, today);//第二个参数减第一个参数System.out.println(period.getYears());System.out.println(period.getMonths());System.out.println(period.getDays());} } public class Demo08Duration {public static void main(String[] args) {// 本地日期时间对象。LocalDateTime today LocalDateTime.now();System.out.println(today);// 出生的日期时间对象LocalDateTime birthDate LocalDateTime.of(2021,8,06,01,00,00);System.out.println(birthDate);Duration duration Duration.between(today , birthDate);//第二个参数减第一个参数System.out.println(duration.toDays());//两个时间差的天数System.out.println(duration.toHours());//两个时间差的小时数System.out.println(duration.toMinutes());//两个时间差的分钟数System.out.println(duration.toMillis());//两个时间差的毫秒数System.out.println(duration.toNanos());//两个时间差的纳秒数} }ChronoUint public class Demo09ChronoUnit {public static void main(String[] args) {// 本地日期时间对象此刻的LocalDateTime today LocalDateTime.now();System.out.println(today);// 生日时间LocalDateTime birthDate LocalDateTime.of(1990,10,1,10,50,59);System.out.println(birthDate);System.out.println(相差的年数 ChronoUnit.YEARS.between(birthDate, today));System.out.println(相差的月数 ChronoUnit.MONTHS.between(birthDate, today));System.out.println(相差的周数 ChronoUnit.WEEKS.between(birthDate, today));System.out.println(相差的天数 ChronoUnit.DAYS.between(birthDate, today));System.out.println(相差的时数 ChronoUnit.HOURS.between(birthDate, today));System.out.println(相差的分数 ChronoUnit.MINUTES.between(birthDate, today));System.out.println(相差的秒数 ChronoUnit.SECONDS.between(birthDate, today));System.out.println(相差的毫秒数 ChronoUnit.MILLIS.between(birthDate, today));System.out.println(相差的微秒数 ChronoUnit.MICROS.between(birthDate, today));System.out.println(相差的纳秒数 ChronoUnit.NANOS.between(birthDate, today));System.out.println(相差的半天数 ChronoUnit.HALF_DAYS.between(birthDate, today));System.out.println(相差的十年数 ChronoUnit.DECADES.between(birthDate, today));System.out.println(相差的世纪百年数 ChronoUnit.CENTURIES.between(birthDate, today));System.out.println(相差的千年数 ChronoUnit.MILLENNIA.between(birthDate, today));System.out.println(相差的纪元数 ChronoUnit.ERAS.between(birthDate, today));} }包装类 public class Test {public static void main(String[] args) {int a 10;Integer a1 11;Integer a2 a; // 自动装箱System.out.println(a);System.out.println(a1);Integer it 100;int it1 it; // 自动拆箱System.out.println(it1);double db 99.5;Double db2 db; // 自动装箱double db3 db2; // 自动拆箱System.out.println(db3);Integer age1 null;System.out.println(——————————————————);// 包装类可以把基本类型到数据转换成字符串形式Integer i3 23;String rs i3.toString();System.out.println(rs 1);System.out.println(——————————————————);String number 23;// 转换成整数//int age Integer.parseInt(number);int age Integer.valueOf(number);System.out.println(age);} } 正则表达式 正则表达式概述、初体验 public class Test {public static void main(String[] args) {// 校验qq号 必须全部数字 6 - 20 位System.out.println(checkQQ(123456789));/*** 结果* true*/}public static boolean checkQQ(String qq) {return (qq ! null qq.matches(\\d{6,20}));} } 正则表达式的匹配规则 public class RegexDemo02 {public static void main(String[] args) {//public boolean matches(String regex):判断是否与正则表达式匹配匹配返回true// 只能是 a b cSystem.out.println(a.matches([abc])); // trueSystem.out.println(z.matches([abc])); // false// 不能出现a b cSystem.out.println(a.matches([^abc])); // falseSystem.out.println(z.matches([^abc])); // trueSystem.out.println(a.matches(\\d)); // falseSystem.out.println(3.matches(\\d)); // trueSystem.out.println(333.matches(\\d)); // falseSystem.out.println(z.matches(\\w)); // trueSystem.out.println(2.matches(\\w)); // trueSystem.out.println(21.matches(\\w)); // falseSystem.out.println(你.matches(\\w)); //falseSystem.out.println(你.matches(\\W)); // trueSystem.out.println(---------------------------------);// 以上正则匹配只能校验单个字符。// 校验密码// 必须是数字 字母 下划线 至少 6位System.out.println(2442fsfsf.matches(\\w{6,}));System.out.println(244f.matches(\\w{6,}));// 验证码 必须是数字和字符 必须是4位System.out.println(23dF.matches([a-zA-Z0-9]{4}));System.out.println(23_F.matches([a-zA-Z0-9]{4}));System.out.println(23dF.matches([\\w[^_]]{4}));System.out.println(23_F.matches([\\w[^_]]{4}));} }正则表达式的常见案例 public class Test {public static void main(String[] args) {// 校验手机号 邮箱 电话号码checkPhone();checkEmail();checkTel();}public static void checkTel() {Scanner sc new Scanner(System.in);while (true) {System.out.println(请输入电话号码);String tel sc.next();// 判断手机号码格式是否正确if(tel.matches(0\\d{2,7}-?\\d{5,20})) {System.out.println(格式正确);break;} else {System.out.println(格式有误请重新输入);System.out.println();}}}public static void checkEmail() {Scanner sc new Scanner(System.in);while (true) {System.out.println(请输入邮箱);String email sc.next();// 判断手机号码格式是否正确if(email.matches(\\w{1,30}[a-zA-Z0-9]{2,20}(\\.[a-zA-Z0-9]{2,20}){1,2})) {System.out.println(邮箱格式正确);break;} else {System.out.println(邮箱有误请重新输入);System.out.println();}}}public static void checkPhone() {Scanner sc new Scanner(System.in);while (true) {System.out.println(请输入手机号);String phone sc.next();// 判断手机号码格式是否正确if(phone.matches(1[3-9]\\d{9})) {System.out.println(手机号码格式正确);break;} else {System.out.println(手机号码有误请重新输入);System.out.println();}}} } 正则表达式在方法中的应用 public class Test {public static void main(String[] args) {String names 小王jkldajfl老王;String[] arrs names.split(\\w);for (int i 0; i arrs.length; i) {System.out.println(arrs[i]);}String names2 names.replaceAll(\\w, );System.out.println(names2);} } 正则表达式爬取信息 Arrays类 Arrays类概述常用功能演示 public class Test {public static void main(String[] args) {int[] arr {10,2,55,23,24,100};System.out.println(arr);// 返回数组内容System.out.println(Arrays.toString(arr));// 对数组元素进行排序默认升序Arrays.sort(arr);System.out.println(Arrays.toString(arr));// 二分搜索技术(前提数组必须排好序否则会出bug)System.out.println(Arrays.binarySearch(arr, 55));} } Arrays类对于Comparator比较器的支持 public class Test {public static void main(String[] args) {// 自定义数组的排序规则// 降序排(自定义比较对象只能支持引用类型排序)Integer[] ages {34, 12, 23, 42};/*** 参数一被排序的数组必须是引用类型的元素* 参数二匿名内部类对象代表了一个比较器对象*/Arrays.sort(ages, new ComparatorInteger() {Overridepublic int compare(Integer o1, Integer o2) {// 自己制定比较规则//return o2 - o1; // 降序return o1 - o2; // 升序}});System.out.println(Arrays.toString(ages));Student[] s new Student[3];s[0] new Student(老王,23);s[1] new Student(老李,25);s[2] new Student(老潘,30);System.out.println(Arrays.toString(s));Arrays.sort(s, new ComparatorStudent() {Overridepublic int compare(Student o1, Student o2) {return o2.getAge() - o1.getAge(); //年龄降序//return Double.compare(o1.getAge(), o2.getAge()); //小数排序}});System.out.println(Arrays.toString(s));} } 常见算法 选择排序 public class Test {public static void main(String[] args) {// 定义数组int[] arr {5 ,1 ,3 ,2};for (int i 0; i arr.length - 1; i) {for (int j i 1; j arr.length; j) {if(arr[i] arr[j]) {//法一arr[j] arr[i] arr[j] - (arr[i] arr[j]);//法二int temp arr[i];arr[i] arr[j];arr[j] temp;//法三arr[i] arr[i] ^ arr[j];arr[j] arr[i] ^ arr[j];arr[i] arr[i] ^ arr[j];}}}System.out.println(Arrays.toString(arr));} } 二分查找 public class Test {public static void main(String[] args) {int[] arr {10, 16 ,20 ,33};System.out.println(binarySearch(arr, 20));}/*** 二分查找算法的实现* param arr 数组* param data 要找的数据* return 返回索引*/public static int binarySearch(int[] arr,int data) {// 定义左位置和右位置int left 0;int right arr.length - 1;// 开始查找while (left right) {// 取中间索引int middleIndex (left right) / 2;// 判断当前中间位置和找的数据的大小情况if (data arr[middleIndex]) {//往右找,左位置更新为中间索引1left middleIndex 1;}else if (data arr[middleIndex]) {//往左找,右位置更新为中间索引-1right middleIndex - 1;}else {return middleIndex;}}return -1; //无data元素} } Lambda表达式枚举 Lambda概述 ​​​​​​​  public class Test {public static void main(String[] args) { // Swimming s () - { // System.out.println(牛逼); // }; // go(s);go(() -{System.out.println(更牛逼);});}public static void go(Swimming s) {System.out.println(游泳);s.swim();System.out.println(哈哈);} }FunctionalInterface //加上这个注释必须是函数是接口且只能又一个抽象方法 interface Swimming {void swim(); } Lambda实战 Lambda表达式的省略规则
http://www.hkea.cn/news/14272053/

相关文章:

  • 网站推广工具网络app开发定制专家公司
  • 个人网站logo需要备案吗营销型网站建设哪里济南兴田德润优惠吗
  • 深圳市罗湖区住房和建设局网站3g手机网站源码
  • 网站漂浮图片公司做英文网站
  • 湖州网站建设有哪些网页制作实践 做网站
  • 宁夏交通厅建设局网站免费做英语卷子的网站
  • 江苏宏澄建设有限公司网站网页设计期末作品源代码
  • 做趣味图形的网站中文html网站模板下载
  • 上海网站公司设计怎么查找网站备案主体
  • 网站备案 核验单网站怎么设置支付
  • 塘沽网站优化海外网站建设推广最好的
  • 福建省文明建设办公室网站seo推广培训
  • 响应式的网站建设一个多少钱建设外贸型网站
  • 成品网站管理系统WordPress网络功能
  • 英文网站建设 淮安国外网站网站app
  • 网站建设基本步骤包括哪些flash怎么做网页
  • 建网页和网站的区别wordpress 快速安装
  • 谁做的四虎网站是多少钱邢台集团网站建设费用
  • 合肥做装修哪个网站好天津市津南区教育网站建设招标
  • 品牌网站建设收费情况深圳深圳建设网站
  • 派点网站建设重庆电力建设公司网站
  • 山西住房建设部网站西部数码网站管理助手 301
  • 做公司网站哪家 上海wordpress修改社交
  • 网站建设开票开什么内容小程序怎么开通
  • 怎么自己开发网站企业如何申请网站
  • 网站功能模块是什么百度广告管家
  • 购物网站建设与开发wordpress做淘宝的交流插件
  • 温州好的网站推广郑州出租车网
  • 做it的网站有哪些wordpress优酷插件
  • 忻州网站建设公司建设银行网站上预览电子回单