java 時間工具類 大于_Java 時間工具類

1 /**

2 * 格式化字符串為日期格式3 *4 *@paramdateStr 需要格式化的字符串5 *@paramformat 需要的日期格式,例如"yyyy-MM-dd HH:mm:ss"6 *@return

7 */

8 public staticDate formatDate(String dateStr, String format) {9 SimpleDateFormat dateFormat = newSimpleDateFormat(format,10 Locale.CHINESE);11 try{12 returndateFormat.parse(dateStr);13 } catch(ParseException e) {14 e.printStackTrace();15 }16

17 return null;18 }19

20 /**

21 * 格式化字符串為"yyyy-MM-dd HH:mm:ss"的日期22 *23 *@paramdateStr24 *@return

25 */

26 public staticDate formatDate(String dateStr) {27 if(StrUtil.isBlank(dateStr)){28 return null;29 }30 return formatDate(dateStr, "yyyy-MM-dd HH:mm:ss");31 }32

33 public static String getFormatDateStr(longdate, String format) {34 return formatDate2Str(newDate(date), format);35 }36

37 public staticString getMonthDayStr(Date date) {38 if (date == null) {39 return "";40 }41 return formatDate2Str(date, "MM-dd");42 }43

44 public staticString getNormalDateStr(Date date) {45 if (date == null) {46 return "";47 }48 return formatDate2Str(date, "yyyy-MM-dd HH:mm:ss");49 }50

51 public staticString formatDate2Str(Date date, String formatter) {52 SimpleDateFormat sdf = newSimpleDateFormat(formatter);53 returnsdf.format(date);54 }55

56 /**

57 * date 日期加上,或減去幾天58 *59 *@paramdate60 *@paramday61 *@return

62 */

63 public static Date addDateInDiff(Date date, intday) {64 Calendar cal =Calendar.getInstance();65 cal.setTime(date);66 cal.add(Calendar.DATE, day);67 returncal.getTime();68 }69

70 public static Date addMinuteInDiff(Date date, intminute) {71 Calendar cal =Calendar.getInstance();72 cal.setTime(date);73 cal.add(Calendar.MINUTE, minute);74 returncal.getTime();75 }76

77 public static Date addSecondInDiff(Date date, intsec) {78 Calendar cal =Calendar.getInstance();79 cal.setTime(date);80 cal.add(Calendar.SECOND, sec);81 returncal.getTime();82 }83

84 /**

85 * 日期加個月86 *87 *@paramdate88 *@parammon89 *@return

90 */

91 public static Date addMonthInDiff(Date date, intmon) {92 Calendar cal =Calendar.getInstance();93 cal.setTime(date);94 cal.add(Calendar.MONTH, mon);95 returncal.getTime();96 }97

98 public static Date addYearInDiff(Date date, intmon) {99 Calendar cal =Calendar.getInstance();100 cal.setTime(date);101 cal.add(Calendar.YEAR, mon);102 returncal.getTime();103 }104

105 /**

106 * 獲取當前日期是星期幾
107 *108 *@paramdt109 *@return當前日期是星期幾110 */

111 public staticString getWeekOfDate(Date dt) {112 String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};113 Calendar cal =Calendar.getInstance();114 cal.setTime(dt);115 int w = cal.get(Calendar.DAY_OF_WEEK) - 1;116 if (w < 0)117 w = 0;118 returnweekDays[w];119 }120

121 /**

122 * 獲取當前日期是周幾
123 *124 *@paramdt125 *@return當前日期是周幾126 */

127 public staticString getWeekOfDate2(Date dt) {128 String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};129 Calendar cal =Calendar.getInstance();130 cal.setTime(dt);131 int w = cal.get(Calendar.DAY_OF_WEEK) - 1;132 if (w < 0)133 w = 0;134 returnweekDays[w];135 }136

137 /**

138 *

139 * 判斷date和當前日期是否在同一周內140 * 注:141 * Calendar類提供了一個獲取日期在所屬年份中是第幾周的方法,對于上一年末的某一天142 * 和新年初的某一天在同一周內也一樣可以處理,例如2012-12-31和2013-01-01雖然在143 * 不同的年份中,但是使用此方法依然判斷二者屬于同一周內144 * 
145 *146 *@paramdate147 *@return

148 */

149 public static booleanisSameWeekWithToday(Date date) {150 return isSameWeek(date, newDate());151 }152

153 public static booleanisSameWeek(Date date1, Date date2) {154 if (date1 == null || date2 == null) {155 return false;156 }157

158 //0.先把Date類型的對象轉換Calendar類型的對象

159 Calendar date1Cal =Calendar.getInstance();160 Calendar date2Cal =Calendar.getInstance();161

162 date1Cal.setTime(date1);163 date2Cal.setTime(date2);164

165 //1.比較當前日期在年份中的周數是否相同

166 if (date1Cal.get(Calendar.WEEK_OF_YEAR) ==date2Cal167 .get(Calendar.WEEK_OF_YEAR)) {168 return true;169 } else{170 return false;171 }172 }173

174 /**

175 * 取得當前日期所在周的第一天176 *177 *@paramdate178 *@return

179 */

180 public staticDate getFirstDayOfWeek(Date date) {181 Calendar c = newGregorianCalendar();182 c.setFirstDayOfWeek(Calendar.MONDAY);183 c.setTime(date);184 c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); //Monday

185 returnc.getTime();186 }187

188 /**

189 * 取得當前日期是多少周190 *191 *@paramdate192 *@return

193 */

194 public static intgetWeekOfYear(Date date) {195 Calendar c = newGregorianCalendar();196 c.setFirstDayOfWeek(Calendar.MONDAY);197 c.setMinimalDaysInFirstWeek(7);198 c.setTime(date);199

200 returnc.get(Calendar.WEEK_OF_YEAR);201 }202

203 /**

204 * 得到某一年周的總數205 *206 *@paramyear207 *@return

208 */

209 public static int getMaxWeekNumOfYear(intyear) {210 Calendar c = newGregorianCalendar();211 c.set(year, Calendar.DECEMBER, 31, 23, 59, 59);212

213 returngetWeekOfYear(c.getTime());214 }215

216 /**

217 * 得到某年某周的第一天218 *219 *@paramyear220 *@paramweek221 *@return

222 */

223 public static Date getFirstDayOfWeek(int year, intweek) {224 Calendar c = newGregorianCalendar();225 c.set(Calendar.YEAR, year);226 c.set(Calendar.MONTH, Calendar.JANUARY);227 c.set(Calendar.DATE, 1);228

229 Calendar cal =(GregorianCalendar) c.clone();230 cal.add(Calendar.DATE, week * 7);231

232 returngetFirstDayOfWeek(cal.getTime());233 }234

235 /**

236 * 得到某年某周的最后一天237 *238 *@paramyear239 *@paramweek240 *@return

241 */

242 public static Date getLastDayOfWeek(int year, intweek) {243 Calendar c = newGregorianCalendar();244 c.set(Calendar.YEAR, year);245 c.set(Calendar.MONTH, Calendar.JANUARY);246 c.set(Calendar.DATE, 1);247

248 Calendar cal =(GregorianCalendar) c.clone();249 cal.add(Calendar.DATE, week * 7);250

251 returngetLastDayOfWeek(cal.getTime());252 }253

254 /**

255 * 取得當前日期所在周的最后一天256 *257 *@paramdate258 *@return

259 */

260 public staticDate getLastDayOfWeek(Date date) {261 Calendar c = newGregorianCalendar();262 c.setFirstDayOfWeek(Calendar.MONDAY);263 c.setTime(date);264 c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); //Sunday

265 returnc.getTime();266 }267

268 /**

269 * 獲得當前日期所在月份的最后一天(最后一個day)270 *271 *@paramdate272 *@returnDate273 */

274 public staticDate getLastDayOfMonth(Date date) {275 Calendar ca =Calendar.getInstance();276 ca.setTime(date);277 ca.set(Calendar.DAY_OF_MONTH,278 ca.getActualMaximum(Calendar.DAY_OF_MONTH));279 returnca.getTime();280 }281

282 public staticDate getFirstDayOfMonth(Date date) {283 Calendar c =Calendar.getInstance();284 c.add(Calendar.MONTH, 0);285 c.set(Calendar.DAY_OF_MONTH, 1);//設置為1號,當前日期既為本月第一天

286 returnc.getTime();287 }288

289 /**

290 * 獲取兩個日期之間的天數291 *292 *@paramstartDate293 *@paramendDate294 *@return

295 */

296 public staticLong getDaysBetween(Date startDate, Date endDate) {297 Calendar fromCalendar =Calendar.getInstance();298 fromCalendar.setTime(startDate);299 fromCalendar.set(Calendar.HOUR_OF_DAY, 0);300 fromCalendar.set(Calendar.MINUTE, 0);301 fromCalendar.set(Calendar.SECOND, 0);302 fromCalendar.set(Calendar.MILLISECOND, 0);303

304 Calendar toCalendar =Calendar.getInstance();305 toCalendar.setTime(endDate);306 toCalendar.set(Calendar.HOUR_OF_DAY, 0);307 toCalendar.set(Calendar.MINUTE, 0);308 toCalendar.set(Calendar.SECOND, 0);309 toCalendar.set(Calendar.MILLISECOND, 0);310

311 return (toCalendar.getTime().getTime() -fromCalendar.getTime()312 .getTime()) / (1000 * 60 * 60 * 24);313 }314

315 /**

316 * 計算兩個分鐘差317 *318 *@return

319 */

320 public staticLong getMinutesBetween(Date startDate, Date endDate) {321 long diff = startDate.getTime() - endDate.getTime();//這樣得到的差值是微秒級別

322 long days = diff / (1000 * 60 * 60 * 24);323

324 long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);325 long minutes = diff / (1000 * 60);326 System.out.println("" + days + "天" + hours + "小時" + minutes + "分");327 returnminutes;328 }329

330 /**

331 * 計算兩個小時差332 *333 *@return

334 */

335 public staticLong getHourBetween(Date startDate, Date endDate) {336 long diff = startDate.getTime() - endDate.getTime();//這樣得到的差值是微秒級別

337 long days = diff / (1000 * 60 * 60 * 24);338

339 long hours = diff / (1000 * 60 * 60);340 System.out.println("" + days + "天" + hours + "小時" + "分");341 returnhours;342 }343

344 /**

345 * 計算兩個秒差346 *347 *@return

348 */

349 public staticLong getSecondBetween(Date startDate, Date endDate) {350 long diff = startDate.getTime() - endDate.getTime();//這樣得到的差值是微秒級別

351 long seconds = diff / (1000);352 returnseconds;353 }354

355 /**

356 * 日期轉換為今天,明天,后天357 * startDate (2018-09-10 00:00:00)358 */

359 public staticString getDateDesc(Date startDate) {360 String todayStr = formatDate2Str(new Date(), "yyyy-MM-dd");361 Date today = formatDate(todayStr + " 00:00:00");362 long days =getDaysBetween(today, startDate);363 if (days == 0) {364 return "今天";365 } else if (days == 1) {366 return "明天";367 } else if (days == 2) {368 return "后天";369 }370 return formatDate2Str(startDate, "yyyy-MM-dd");371 }372

373 /**

374 * 顯示時間,如果與當前時間差別小于一天,則自動用**秒(分,小時)前,如果大于一天則用format規定的格式顯示375 *376 *@paramctime 時間377 *@paramformat 格式 格式描述:例如:yyyy-MM-dd yyyy-MM-dd HH:mm:ss378 *@return

379 */

380 public staticString showTime(Date ctime, String format) {381 //System.out.println("當前時間是:"+new382 //Timestamp(System.currentTimeMillis()));383

384 //System.out.println("發布時間是:"+df.format(ctime).toString());

385 String r = "";386 if (ctime == null)387 returnr;388 if (format == null)389 format = "MM-dd HH:mm";390

391 boolean isSameYear = isSameYear(ctime, newDate());392 if (!isSameYear) {393 format = "yy-M-d";394 SimpleDateFormat df = newSimpleDateFormat(format);395 returndf.format(ctime);396 }397

398 long nowtimelong =System.currentTimeMillis();399

400 long ctimelong =ctime.getTime();401 long result = Math.abs(nowtimelong -ctimelong);402

403 if (result < 60000) {//一分鐘內404 //long seconds = result / 1000;405 //if(seconds == 0){406 //r = "剛剛";407 //}else{408 //r = seconds + "秒前";409 //}

410 r = "剛剛";411 } else if (result >= 60000 && result < 3600000) {//一小時內

412 long seconds = result / 60000;413 r = seconds + "分鐘前";414 } else if (result >= 3600000 && result < 86400000) {//一天內

415 long seconds = result / 3600000;416 r = seconds + "小時前";417 } else if (result > 86400000 && result < 172800000) {//三十天內418 //long seconds = result / 86400000;419 //r = seconds + "天前";

420 r = "昨天";421 } else if (result >= 172800000) {422 //format = "M-d";

423 SimpleDateFormat df = newSimpleDateFormat(format);424 r =df.format(ctime).toString();425 }426 //else{//日期格式427 //format="MM-dd HH:mm";428 //SimpleDateFormat df = new SimpleDateFormat(format);429 //r = df.format(ctime).toString();430 //}

431 returnr;432 }433

434 public static booleanisSameYear(Date ctime, Date nTime) {435 Calendar cDate =Calendar.getInstance();436 cDate.setTime(ctime);437 Calendar nDate =Calendar.getInstance();438 nDate.setTime(nTime);439 int cYear =cDate.get(Calendar.YEAR);440 int nYear =nDate.get(Calendar.YEAR);441 if (cYear ==nYear) {442 return true;443 }444 return false;445 }446

447 /***448 * 出生日期轉換年齡449 ***/

450 public static intgetAgeByBirthday(Date birthday) {451 Calendar cal =Calendar.getInstance();452 if (birthday.getTime() > newDate().getTime()) {453 return 0;454 }455 int year =cal.get(Calendar.YEAR);456 int month = cal.get(Calendar.MONTH) + 1;457 int day =cal.get(Calendar.DAY_OF_MONTH);458

459 cal.setTime(birthday);460 int yearBirth =cal.get(Calendar.YEAR);461 int monthBirth = cal.get(Calendar.MONTH) + 1;462 int dayBirth =cal.get(Calendar.DAY_OF_MONTH);463 int age = year -yearBirth;464 if (monthBirth >month)465 return age - 1;466 if (monthBirth == month && dayBirth >day)467 return age - 1;468 return age > 0 ? age : 0;469 }470

471 /***472 * 根據年齡取得出生日期473 *474 *@paramage475 *@return

476 */

477 public static String getBirthdayByAge(intage) {478 Calendar cal =Calendar.getInstance();479 int year =cal.get(Calendar.YEAR);480 int month = cal.get(Calendar.MONTH) + 1;481 int day =cal.get(Calendar.DAY_OF_MONTH);482 int birthYear = year -age;483 Date birthDay = formatDate(birthYear + "-" + month + "-" +day,484 "yyyy-MM-dd");485 return formatDate2Str(birthDay, "yyyy-MM-dd");486 }487

488

489 /**

490 * 判斷結束時間是否早于當前時間491 **/

492 public static booleanisTimeout(String date) {493 if (date == null)494 return false;495 long now = newDate().getTime();496 long end =formatDate(date.toString()).getTime();497 if (now >end)498 return true;499 return false;500 }501

502 /**

503 *@paramdate504 *@return

505 */

506 public static booleanisTimeout(Date date) {507 if (date == null) return false;508 long now = newDate().getTime();509 long end =date.getTime();510 if (now > end) return true;511 return false;512 }513

514 /**

515 * 判斷date2時間是否早于date1時間516 **/

517 public static booleanisTimeout(String date1, String date2) {518 if (date1 == null || date2 == null)519 return false;520 long start =formatDate(date2.toString()).getTime();521 long end =formatDate(date1.toString()).getTime();522 if (start >end)523 return true;524 return false;525 }526

527 /**

528 * 判斷傳入的時間是否已滿一周年529 */

530 public static booleanisLastYear(Date date) {531 Calendar calendar =Calendar.getInstance();532 Date lastYear = newDate(System.currentTimeMillis());533 calendar.setTime(lastYear);534 calendar.add(Calendar.YEAR, -1);535 lastYear =calendar.getTime();536 if (date.getTime()

542 public static intgetSpecVoteFailTime() {543 Date nowDate = newDate();544 Date addDateInDiff = addDateInDiff(nowDate, 1);545 String endDateStr = formatDate2Str(addDateInDiff, "yyyy-MM-dd") + " 00:00:00";546 Date formatDate =formatDate(endDateStr);547 long time1 =formatDate.getTime();548 long time2 =nowDate.getTime();549 long abs = Math.abs(time1 -time2);550 long l = abs / 1000;551 returnInteger.valueOf(String.valueOf(l));552 }553

554 //2018-09-17 9時 轉成日期格式

555 public staticString convertShowTimeToDate(String date) {556 StringBuilder str = newStringBuilder();557 str.append(date);558 if (date.length() == 13) {559 str.insert(11, 0);560 }561 date = date.replace("時", ":00:00");562 System.out.println(date);563 returndate;564 }565

566 //日期格式轉成2018-09-17 9時

567 public staticString convertDateToShowTime(Date date) {568 String dateStr = UtilDate.formatDate2Str(date, "yyyy-MM-dd HH");569 String regx = "\\s0";570 dateStr = dateStr.replaceAll(regx, " ") + "時";571 System.out.println(dateStr);572 returndateStr;573 }574

575

576 /**

577 * 第幾個工作日578 *579 *@paramdate580 *@paramdays581 *@return

582 */

583 public static Date getWorkDte(Date date, intdays) {584

585 Calendar calendar =Calendar.getInstance();586 calendar.setTime(date);587 if (days > 0) {588 for (int i = 1; i <= days; i++) {589 calendar.add(Calendar.DAY_OF_YEAR, 1);590 if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) ==Calendar.SUNDAY) {591 i--;592 }593 }594 } else if (days < 0) {595 for (int i = 0; i > days; i--) {596 calendar.add(Calendar.DAY_OF_YEAR, -1);597 if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) ==Calendar.SUNDAY) {598 i++;599 }600 }601 }602 returncalendar.getTime();603 }604

605 /**

606 * 幾小時幾分鐘607 *608 *@paramseconds609 *@return

610 */

611 public static String getTimeStrBySeconds(intseconds) {612 String timeStr = "";613 int hour = seconds / (60 * 60);614 int minute = seconds % (60 * 60) / 60;615 if (0 ==hour) {616 timeStr = seconds % (60 * 60) / 60 + "分鐘";617

618 } else{619 timeStr = seconds / (60 * 60) + "小時" + seconds % (60 * 60) / 60 + "分鐘";620

621 }622 returntimeStr;623 }624

625 //判斷選擇的日期是否是本周

626 public static boolean isThisWeek(longtime)627 {628 Calendar calendar =Calendar.getInstance();629 int currentWeek =calendar.get(Calendar.WEEK_OF_YEAR);630 calendar.setTime(newDate(time));631 int paramWeek =calendar.get(Calendar.WEEK_OF_YEAR);632 if(paramWeek==currentWeek){633 return true;634 }635 return false;636 }637 //判斷選擇的日期是否是今天

638 public static boolean isToday(longtime)639 {640 return isThisTime(time,"yyyy-MM-dd");641 }642 //判斷選擇的日期是否是本月

643 public static boolean isThisMonth(longtime)644 {645 return isThisTime(time,"yyyy-MM");646 }647 private static boolean isThisTime(longtime,String pattern) {648 Date date = newDate(time);649 SimpleDateFormat sdf = newSimpleDateFormat(pattern);650 String param = sdf.format(date);//參數時間

651 String now = sdf.format(new Date());//當前時間

652 if(param.equals(now)){653 return true;654 }655 return false;656 }657

658 /**

659 * 當天時間獲取時分660 *@return

661 */

662 public staticString getIsTodayStartTime(Date date){663 //Date date = UtilDate.formatDate(time, "yyyy-MM-dd HH:mm");

664 long time1 =date.getTime();665 boolean today =UtilDate.isToday(time1);666 String todayTime = UtilDate.getFormatDateStr(date.getTime(),"yyyy-MM-dd HH:mm");667 if(today){668

669 String regex = " ";670 String[] split =todayTime.split(regex);671 return "今天 " + split[1];672 }673 returntodayTime;674 }675

676 /**

677 * 當天時間獲取時分678 *@return

679 */

680 public staticString getIsTodayEndTime(Date date){681 //Date date = UtilDate.formatDate(time, "yyyy-MM-dd HH:mm");

682 long time1 =date.getTime();683 boolean today =UtilDate.isToday(time1);684 String todayTime = UtilDate.getFormatDateStr(date.getTime(),"yyyy-MM-dd HH:mm");685 if(today){686 String regex = " ";687 String[] split =todayTime.split(regex);688 return split[1];689 }690 return todayTime.substring(11);691 }

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/272832.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/272832.shtml
英文地址,請注明出處:http://en.pswp.cn/news/272832.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

IP、TCP和DNS與HTTP的密切關系

看了上一篇博文的發表時間&#xff0c;是7月22日&#xff0c;現在是10月22日&#xff0c;已經有三個月沒寫博客了。這三個月里各種忙各種瞎折騰&#xff0c;發生了很多事情&#xff0c;也思考了很多問題。現在這段時間開始閑下來了&#xff0c;同時該思考的事情也思考清楚了&am…

C# 委托的理解

1、什么是委托委托可以理解為持有一個或多個方法的對象。如果執行委托的話&#xff0c;委托會執行它所"持有"的方法。委托可以避免程序中大量使用if-else語句&#xff0c;使程序擁有更好的擴展性。2、委托的本質委托和類一樣&#xff0c;是一種用戶自定義的類型&…

java基礎判斷題_java基礎知識周測試題帶答案

簡單題(每題5分&#xff0c;共計50分)簡述Java語言跨平臺的原理Java跨平臺的特性&#xff0c;也就是同一份字節碼文件可以在不同的系統上執行&#xff0c;由不同系統中的Java虛擬機負責翻譯成對應的機器指令。寫出以下名詞的概念和各自作用jre - Java運行時環境信息&#xff0c…

SQLSERVER 2008 R2版本密鑰(摘)

開發版32位&#xff1a;MC46H-JQR3C-2JRHY-XYRKY-QWPVM開發版64位&#xff1a;FTMGC-B2J97-PJ4QG-V84YB-MTXX8工組版&#xff1a;XQ4CB-VK9P3-4WYYH-4HQX3-K2R6QWEB版&#xff1a;FP4P7-YKG22-WGRVK-MKGMX-V9MTM數據中心版32位&#xff1a;PTTFM-X467G-P7RH2-3Q6CG-4DMYB數據中…

java conf_JAVA 解析、編輯nginx.conf

最近工程開發遇到一個需求&#xff1a;用Java去解析并編輯nginx.conf解析nginx.conf過程可以參考該項目的README.md下面舉個列子說明一下該如何編輯nginx.conf。定義一個pojoimportcom.alibaba.fastjson.JSONArray;importcom.google.common.base.Strings;importlombok.Data;Dat…

【原創】關于ASP.NET WebForm與ASP.NET MVC的比較

WebForm的理解1、 WebForm概念ASP.NETWebform提供了一個類似于Winform的事件響應GUI模型&#xff08;event-drivenGUI&#xff09;&#xff0c;隱藏了HTTP、HTML、JavaScript等細節&#xff0c;將用戶界面構建成一個服務器端的樹結構控件&#xff08;Control&#xff09;&#…

對象的接口

Simula(模擬) 是一個很好的列子。正如這個名字鎖暗示的&#xff0c;它的作用是"模擬"像"銀行出納員"我們有一系列出納員,客戶,賬戶以及交易等 每類成員(元素)都有具有一些通用的特征,每個賬號都有一定的余額;每個出納都能接收客戶的存款&#xff0c;等等。…

java color類 藍色_java中Color類的簡單總結

標簽&#xff1a;java中Color類的簡單總結1.顏色的常識任何顏色都是由三原色組成(RGB),JAVA中支持224為彩色&#xff0c;即紅綠藍分量取值介于0-255之間(8位表示)2.Color類中的常量public final static Color black new Color(0,0,0);public final static Color bule new Col…

C#中幾種循環語法的比較

循環操作在程序開發當中使用非常的廣泛&#xff0c;當然循環也很容易成為整個程序運行的性能瓶頸&#xff0c;所以理解C#中幾種循環的用法&#xff0c;還是非常重要的。C#支持一下四種循環方式1、while循環2、do...while循環3、for 循環4、foreach循環前三種循環在C、Java中也是…

Eclipse基金會

昨天Eclipse基金會慶祝其成立十周年。2004年2月的新聞稿宣布該非盈利組織的正式成立&#xff0c;由包括開發者、消費者和插件提供商在內的各獨立團體組成的董事會&#xff0c;為Eclipse的長期發展負責。 基金會成立時&#xff0c;有19個項目和50個董事會成員&#xff0c;其開源…

.Net架構必備工具列表

原文N多年前微軟官網曾發了.Net下必備的十種工具&#xff0c;N多年過去了&#xff0c;世異時移&#xff0c;很多東西都已經變化了&#xff0c;那個列表也似乎陳舊了。而且&#xff0c;該文也只是對十種工具獨立的介紹&#xff0c;顯得有些羅列的感覺&#xff0c;是不是每個工具…

java scanner接收數組_java – 使用scanner將文件中的整數讀入數組

我正在為學校做一份復習工作.賦值是編寫一個類,它從標準輸入讀取一個包含幾個整數的文件,這些整數將被放入一個數組中.從這里開始,需要編寫方法來找出平均值,中位數,最大值,最小值和標準差.它讀起來像這樣&#xff1a;4556677889等等…所以,我假設我需要創建一個數組列表(因為長…

Asp.Net頁面傳值的方法簡單總結【原創】

1、QueryString當頁面上form按照get的方式向頁面發送請求數據的時候&#xff0c;web server會將請求數據放入一個QEURY_STRING的環境變量中&#xff0c;然后通過QeueryString方法從這個變量中獲取相應的參數。例如&#xff1a;發送參數頁面Test1.aspx 按鈕單擊代碼&#xff1a;…

關于archlinux下的ralink5370網卡

驅動此網卡要使用 rt2800usb&#xff0c;rt2800lib 這兩個模塊 順便說一下對模塊進行操作的命令&#xff1a; rmmod 模塊名 //為移除模塊 insmod 模塊所在路徑 //為添加模塊 查看網卡是否能被驅動&#xff0c;可以使用命令&#xff1a;ifconfig -a 轉載于:https://www.cnblogs.…

java xml 遞歸_Java遞歸遍歷XML所有元素

import org.dom4j.Document;import org.dom4j.DocumentHelper;import org.dom4j.DocumentException;import org.dom4j.Element;import java.util.*;/*** Created by IntelliJ IDEA.* User: leizhimin* Date: 2008-4-14 14:02:12* Note: Java遞歸遍歷XML所有元素*/public class …

【基礎】C#異常處理的總結

一、異常處理的理解&#xff1f;異常處理是指程序在運行過程中&#xff0c;發生錯誤會導致程序退出&#xff0c;這種錯誤&#xff0c;就叫做異常。因此處理這種錯誤&#xff0c;就稱為異常處理。二、異常處理如何操作&#xff1f;C# 異常處理時建立在四個關鍵詞之上的&#xff…

Java Web 路徑問題

可能在做文件上傳或者 圖片加載&#xff0c;資源加載 時候用到文件相對服務器地址 System.out.println(request.getRemoteUser()); //客戶端用戶System.out.println(request.getRemoteAddr()); //客戶端IPSystem.out.println(request.getRemoteHost()); //客戶端主機名Syst…

mysql 多字節編碼漏洞_phpmyadmin 4.8.1 遠程文件包含漏洞(CVE-2018-12613)

漏洞詳情范圍 phpMyAdmin 4.8.0和4.8.1原理 首先在index.php 50-63行代碼$target_blacklist array (import.php, export.php);// If we have a valid target, lets load that script insteadif (! empty($_REQUEST[target])&& is_string($_REQUEST[target])&&…

.Net開發的兩個小技巧

一、符號的妙用1、可以作為保留關鍵字的標識符C#規范當中&#xff0c;不允許使用保留關鍵字&#xff08;class、bool等&#xff09;當作普通的標識符來命名&#xff0c;這時候符號作用就體現出來了&#xff0c;可以通過符號前綴把這些保留關鍵字可以當作普通的字符使用。比如&a…

Codeforces Round #FF (Div. 1) A. DZY Loves Sequences

原題鏈接&#xff1a;http://codeforces.com/problemset/problem/446/A 題意&#xff1a;給一個長度為n的序列&#xff0c;最多可以修改一個位置的數&#xff0c;求最長連續上升子序列。 題解&#xff1a;當a[i1] > a[i-1]2的時候&#xff0c;可以通過改變a[i]的值來使前后兩…