java 如何從字符串里面提取時(shí)間
如何從字符串里面提取時(shí)間
今天接到一個(gè)需求,需要從一段帶有時(shí)間串的字符串里面提取出時(shí)間保存。
"PDFS(iZh9k5gurgwcwpZ) 2020-01-01 21:27:36.560 >訂單編號:1112233 提交訂單成功! 跟蹤號:待取跟蹤號 內(nèi)部單號:2342244"
需要從上面數(shù)據(jù)中心提取出 2020-01-01 21:27:36要怎么操作呢?
我們可以使用正則表達(dá)式
對時(shí)間串進(jìn)行提取,并處理,代碼如下:
package com.epean.trade.framework.util; import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateUtils; import java.text.ParseException; import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Created by chpeng on 2020/08/18 0008. */ public class StringDateUtils { /** * * @Description: 從字符串中截取出正確的時(shí)間 * @param stringTime * @return: * @throws */ public static Date cutDate(String stringTime) { String regs[] = { "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}年\\d{2}月\\d{2}日\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{4}年\\d{2}月\\d{2}日\\d{2}時(shí)\\d{2}分", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}時(shí)", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{1}時(shí)", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}時(shí)", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{1}時(shí)", "\\d{4}年\\d{2}月\\d{2}日\\d{2}時(shí)", "\\d{4}年\\d{2}月\\d{2}日", "\\d{4}年\\d{2}月\\d{1}日", "\\d{4}年\\d{1}月\\d{2}日", "\\d{4}年\\d{1}月\\d{1}日", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}:\\d{1}:\\d{2}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}:\\d{1}:\\d{2}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\d{2}:\\d{2}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{1}:\\d{2}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}:\\d{2}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{1}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\d{2}:\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{2}", "\\d{4}年\\d{2}月\\d{2}日\\s\\d{1}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{2}", "\\d{4}年\\d{1}月\\d{2}日\\s\\d{1}", "\\d{4}年\\d{2}月\\d{2}日\\d{2}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}-\\d{1}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}-\\d{1}-\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{1}:\\d{2}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}", "\\d{4}-\\d{2}-\\d{2}", "\\d{4}-\\d{2}-\\d{1}", "\\d{4}-\\d{1}-\\d{2}", "\\d{4}-\\d{1}-\\d{1}", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}-\\d{2}-\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}-\\d{1}-\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}-\\d{1}-\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}-\\d{1}-\\d{1}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{4}-\\d{2}-\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{4}-\\d{1}-\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{4}-\\d{1}-\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{4}-\\d{2}-\\d{2}\\s\\d{2}時(shí)", "\\d{4}-\\d{2}-\\d{2}\\s\\d{1}時(shí)", "\\d{4}-\\d{1}-\\d{2}\\s\\d{2}時(shí)", "\\d{4}-\\d{1}-\\d{2}\\s\\d{1}時(shí)", "\\d{4}.\\d{2}.\\d{2}", "\\d{4}.\\d{2}.\\d{1}", "\\d{4}.\\d{1}.\\d{2}", "\\d{4}.\\d{1}.\\d{1}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}.\\d{1}.\\d{1}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{2}:\\d{2}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{1}:\\d{2}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{2}:\\d{2}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{1}:\\d{2}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{2}", "\\d{4}.\\d{2}.\\d{2}\\s\\d{1}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{2}", "\\d{4}.\\d{1}.\\d{2}\\s\\d{1}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}時(shí)", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}時(shí)", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}時(shí)", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}時(shí)", "\\d{4}/\\d{2}/\\d{2}", "\\d{4}/\\d{2}/\\d{1}", "\\d{4}/\\d{1}/\\d{2}", "\\d{4}/\\d{1}/\\d{1}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}:\\d{2}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}:\\d{2}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}:\\d{2}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}:\\d{2}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{2}", "\\d{4}/\\d{2}/\\d{2}\\s\\d{1}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{2}", "\\d{4}/\\d{1}/\\d{2}\\s\\d{1}", "\\d{2}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{2}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{1}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{2}月\\d{2}日\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{2}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{1}月\\d{2}日\\s\\d{1}時(shí)\\d{2}分", "\\d{1}月\\d{2}日\\s\\d{2}時(shí)\\d{2}分", "\\d{2}月\\d{2}日\\d{2}時(shí)\\d{2}分", "\\d{2}月\\d{2}日\\s\\d{2}時(shí)", "\\d{2}月\\d{2}日\\s\\d{1}時(shí)", "\\d{1}月\\d{2}日\\s\\d{2}時(shí)", "\\d{1}月\\d{2}日\\s\\d{1}時(shí)", "\\d{2}月\\d{2}日\\d{2}時(shí)", "\\d{4}年\\d{2}月\\d{2}日", "\\d{2}月\\d{1}日", "\\d{4}年\\d{1}月\\d{2}日", "\\d{1}月\\d{1}日", "\\d{2}月\\d{2}日\\s\\d{2}:\\d{2}:\\d{2}", "\\d{2}月\\d{2}日\\s\\d{2}:\\d{1}:\\d{2}", "\\d{1}月\\d{2}日\\s\\d{2}:\\d{1}:\\d{2}", "\\d{1}月\\d{2}日\\s\\d{2}:\\d{2}:\\d{2}", "\\d{2}月\\d{2}日\\d{2}:\\d{2}:\\d{2}", "\\d{2}月\\d{2}日\\s\\d{2}:\\d{2}", "\\d{2}月\\d{2}日\\s\\d{1}:\\d{2}", "\\d{1}月\\d{2}日\\s\\d{2}:\\d{2}", "\\d{1}月\\d{2}日\\s\\d{1}:\\d{2}", "\\d{2}月\\d{2}日\\d{2}:\\d{2}", "\\d{2}月\\d{2}日\\s\\d{2}", "\\d{2}月\\d{2}日\\s\\d{1}", "\\d{1}月\\d{2}日\\s\\d{2}", "\\d{1}月\\d{2}日\\s\\d{1}", "\\d{2}月\\d{2}日\\d{2}", "\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{2}-\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{1}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{1}-\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{2}-\\d{2}\\s\\d{2}:\\d{2}", "\\d{2}-\\d{2}\\s\\d{1}:\\d{2}", "\\d{2}-\\d{2}\\s\\d{2}", "\\d{4}-\\d{2}-\\d{2}", "\\d{2}-\\d{1}", "\\d{4}-\\d{1}-\\d{2}", "\\d{1}-\\d{1}", "\\d{2}-\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{2}-\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{1}-\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{1}-\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{1}-\\d{1}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{2}-\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{2}-\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{1}-\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{1}-\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{2}-\\d{2}\\s\\d{2}時(shí)", "\\d{2}-\\d{2}\\s\\d{1}時(shí)", "\\d{1}-\\d{2}\\s\\d{2}時(shí)", "\\d{1}-\\d{2}\\s\\d{1}時(shí)", "\\d{4}.\\d{2}.\\d{2}", "\\d{2}.\\d{1}", "\\d{4}.\\d{1}.\\d{2}", "\\d{1}.\\d{1}", "\\d{2}.\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{2}.\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{1}.\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{1}.\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{1}.\\d{1}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{2}.\\d{2}\\s\\d{2}:\\d{2}", "\\d{2}.\\d{2}\\s\\d{1}:\\d{2}", "\\d{1}.\\d{2}\\s\\d{2}:\\d{2}", "\\d{1}.\\d{2}\\s\\d{1}:\\d{2}", "\\d{2}.\\d{2}\\s\\d{2}", "\\d{2}.\\d{2}\\s\\d{1}", "\\d{1}.\\d{2}\\s\\d{2}", "\\d{1}.\\d{2}\\s\\d{1}", "\\d{2}/\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{2}/\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{1}/\\d{2}\\s\\d{2}時(shí)\\d{2}分\\d{2}秒", "\\d{1}/\\d{2}\\s\\d{1}時(shí)\\d{2}分\\d{2}秒", "\\d{2}/\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{2}/\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{1}/\\d{2}\\s\\d{2}時(shí)\\d{2}分", "\\d{1}/\\d{2}\\s\\d{1}時(shí)\\d{2}分", "\\d{2}/\\d{2}\\s\\d{2}時(shí)", "\\d{2}/\\d{2}\\s\\d{1}時(shí)", "\\d{1}/\\d{2}\\s\\d{2}時(shí)", "\\d{1}/\\d{2}\\s\\d{1}時(shí)", "\\d{2}/\\d{2}", "\\d{2}/\\d{1}", "\\d{1}/\\d{2}", "\\d{1}/\\d{1}", "\\d{2}/\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{2}/\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{1}/\\d{2}\\s\\d{2}:\\d{2}:\\d{2}", "\\d{1}/\\d{2}\\s\\d{1}:\\d{2}:\\d{2}", "\\d{2}/\\d{2}\\s\\d{2}:\\d{2}", "\\d{2}/\\d{2}\\s\\d{1}:\\d{2}", "\\d{1}/\\d{2}\\s\\d{2}:\\d{2}", "\\d{1}/\\d{2}\\s\\d{1}:\\d{2}", "\\d{2}/\\d{2}\\s\\d{2}", "\\d{2}/\\d{2}\\s\\d{1}", "\\d{1}/\\d{2}\\s\\d{2}", "\\d{1}/\\d{2}\\s\\d{1}", }; String str = ""; Date date = null; for (String reg : regs) { String temp = match(reg, stringTime); if (temp.length() > str.length()) { str = temp; if (!"".equals(str)) { date = formatDate(str); } } } return date; } /** * * @Description: 把String格式的時(shí)間轉(zhuǎn)化為date * @param stringTime * @return: * @throws */ public static Date formatDate(String stringTime) { Date date = null; if (StringUtils.isNotBlank(stringTime)) { String[] pattern = new String[] { "yyyy年MM月dd日HH時(shí)mm分ss秒", "yyyy年MM月dd日 HH時(shí)mm分ss秒", "yyyy年MM月dd日HH時(shí)mm分", "yyyy年MM月dd日 HH時(shí)mm分", "yyyy年MM月dd日 HH時(shí)", "yyyy年MM月dd日HH時(shí)", "yyyy年MM月dd日", "yyyy年MM月dd日HH:mm:ss", "yyyy年MM月dd日 HH:mm:ss", "yyyy年MM月dd日HH:mm", "yyyy年MM月dd日 HH:mm", "yyyy年MM月dd日 HH", "yyyy年MM月dd日HH", "yyyy-MM-dd HH時(shí)mm分ss秒", "yyyy-MM-dd HH時(shí)mm分", "yyyy-MM-dd HH時(shí)", "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH", "yyyy/MM/dd HH時(shí)mm分ss秒", "yyyy/MM/dd HH時(shí)mm分", "yyyy/MM/dd HH時(shí)", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM/dd HH", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM.dd HH", "yyyy.MM.dd", "yyyyMMdd", }; try { date = DateUtils.parseDate(stringTime, pattern); } catch (ParseException e) { e.printStackTrace(); } } return date; } public static String match(String reg, String stringTime) { Pattern p = Pattern.compile(reg); Matcher m = p.matcher(stringTime); String s = ""; if (m.find()) { s += m.group(); } return s; } /** * 格式化 * @Title: DateToString * @Description: * @param time * @return: * @throws */ public static String DateToString(Date time) { String newDate = DateFormatUtils.format(time,"yyyy-MM-dd HH:mm:ss"); return newDate; } public static void main(String[] args) { String stringTime = "PDFS(iZh9k5gurgwcwpZ) 2020-01-01 21:27:36.560 >訂單編號:1112233 提交訂單成功! 跟蹤號:待取跟蹤號 內(nèi)部單號:2342244"; Date date = cutDate(stringTime); System.out.println(date); System.out.println(DateToString(date)); } }
我們測試一下:
沒問題的。
從字符串中提取年份,要求輸出1000-4999之間的所有年份
正則表達(dá)式
常用正則表達(dá)式:
\d
: 數(shù)字字符匹配。等效于 [0-9]\D
: 非數(shù)字字符匹配。等效于 [^0-9]。{n}
: n為非負(fù)整數(shù),正好匹配n次{n,}
: n為非負(fù)整數(shù),至少匹配n次[a-z]
: 字符范圍。匹配指定范圍內(nèi)的任何字符,例如,"[a-z]"匹配"a"到"z"范圍內(nèi)的任何小寫字母。[^a-z]
: 反向范圍字符。匹配不在指定的范圍內(nèi)的任何字符。例如,"[^a-z]"匹配任何不在"a"到"z"范圍內(nèi)的任何字符。\
: 將下一字符標(biāo)記為特殊字符、文本、反向引用或八進(jìn)制轉(zhuǎn)義符^
: 匹配輸入字符串開始的位置$
: 匹配輸入字符串結(jié)尾的位置。*
: 零次或多次匹配前面的字符或子表達(dá)式。例如,zo* 匹配"z"和"zoo"。* 等效于 {0,}+
: 一次或多次匹配前面的字符或子表達(dá)式。例如,"zo+"與"zo"和"zoo"匹配,但與"z"不匹配。+ 等效于 {1,}。?
: 零次或一次匹配前面的字符或子表達(dá)式。例如,"do(es)?"匹配"do"或"does"中的"do"。? 等效于 {0,1}。
import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class JingDong { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); String reg = "\\D[1-4]\\d{3}\\D";//eg:a2019a、a2019、2019a // 前面不能是數(shù)字,后面也不能是數(shù)字 str = str +"a"; str = "a" + str; Pattern p = Pattern.compile(reg); Matcher matcher = p.matcher(str); while(matcher.find()){ System.out.print(matcher.group(0).substring(1,5) + " "); } } public static boolean isNum(char a){ if(Character.isDigit(a)){ return true; }else return false; } }
傳統(tǒng)匹配:
import java.util.*; public class JingDong { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); if(str.length()<=2000){ String out = ""; for (int i = 0; i < str.length()-1;) { if(isNum(str.charAt(i) )&& Integer.parseInt(String.valueOf(str.charAt(i))) <=4 && Integer.parseInt(String.valueOf(str.charAt(i)))>=1){ if(isNum(str.charAt(i+1))){ if(isNum(str.charAt(i+2))){ if(isNum(str.charAt(i+3))){ if (!isNum(str.charAt(i+4))){ out += str.substring(i,i+4); out += " "; i+=4; } i+=4; }else i++; }else i++; }else i++; }else i++; } System.out.println(out); } public static boolean isNum(char a){ if(Character.isDigit(a)){ return true; }else return false; } }
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
springboot全局字符編碼設(shè)置方式(解決亂碼問題)
這篇文章主要介紹了springboot全局字符編碼設(shè)置方式(解決亂碼問題),具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12jdk7 中HashMap的知識點(diǎn)總結(jié)
HashMap的原理是老生常談了,不作仔細(xì)解說。一句話概括為HashMap是一個(gè)散列表,它存儲的內(nèi)容是鍵值對(key-value)映射。這篇文章主要總結(jié)了關(guān)于jdk7 中HashMap的知識點(diǎn),需要的朋友可以參考借鑒,一起來看看吧。2017-01-01Spring實(shí)現(xiàn)定時(shí)任務(wù)的幾種方式總結(jié)
Spring Task 是 Spring 框架提供的一種任務(wù)調(diào)度和異步處理的解決方案,可以按照約定的時(shí)間自動執(zhí)行某個(gè)代碼邏輯它可以幫助開發(fā)者在 Spring 應(yīng)用中輕松地實(shí)現(xiàn)定時(shí)任務(wù)、異步任務(wù)等功能,提高應(yīng)用的效率和可維護(hù)性,需要的朋友可以參考下本文2024-07-07Spring的IOC解決程序耦合的實(shí)現(xiàn)
本文主要介紹了Spring的IOC解決程序耦合的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-07-07教你在一分鐘之內(nèi)理解Java Lambda表達(dá)式并學(xué)會使用
今天給大家?guī)У奈恼率荍ava8新特性的相關(guān)知識,文章圍繞著如何在一分鐘之內(nèi)理解Java Lambda表達(dá)式并學(xué)會使用展開,文中有非常詳細(xì)的介紹,需要的朋友可以參考下2021-06-06Java 創(chuàng)建動態(tài)類和查看方法列表信息的實(shí)例
這篇文章主要介紹了 Java 創(chuàng)建動態(tài)類和查看方法列表信息的實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-06-06