如果需要在西日本做長程移動的時候,山陽&山陰地區鐵路周遊券 滿足你新幹線搭好搭滿的旅程
例如:
從新大阪移動到姫路 -新幹線(30分) 3950円,來回就 7900円。或是 從新大阪移動到岡山 -新幹線(45分) 6020円,來回就 12040円。
更不用提如果是西日本大貫走,從九州的福岡一路玩到京都了,整個福到爆炸
(當然當然,值不值得買這個問題,請先把你的行程排出來,再決定要買哪些票券才是規劃行程的方式)
如果需要在西日本做長程移動的時候,山陽&山陰地區鐵路周遊券 滿足你新幹線搭好搭滿的旅程
例如:
從新大阪移動到姫路 -新幹線(30分) 3950円,來回就 7900円。或是 從新大阪移動到岡山 -新幹線(45分) 6020円,來回就 12040円。
更不用提如果是西日本大貫走,從九州的福岡一路玩到京都了,整個福到爆炸
(當然當然,值不值得買這個問題,請先把你的行程排出來,再決定要買哪些票券才是規劃行程的方式)
2018要準備追櫻了喔~
1月的預測基本上當做看看就好,提供給要買機票的人做參考
比較準確的預測需要等到3月,除非天氣忽然劇變,不然估計結果八九不離十
(計算櫻花類型各有不同,各家公司主要依 染井吉野(ソメイヨシノ)做為開花估計 )
清明連假到底幾家歡樂幾家愁?我的話呢,應該是會碰到被櫻花花瓣打臉的花況吧
2018 氣象廳公佈標本木開花時間: |
HttpServletResponse res; //Cache-Control HTTP1.1 //Pragma Expires HTTP1.0 res.setHeader( "Pragma", "no-cache" ); //與Cache-Control: no-cache相同,會被Cache-Control覆蓋 res.addHeader( "Cache-Control", "must-revalidate" ); res.addHeader( "Cache-Control", "no-cache" ); //發request向server確認是否取得新資料 res.addHeader( "Cache-Control", "no-store" ); //完全不Cache res.setDateHeader("Expires", 0); //CACHE過期時間,與Cache-Control: max-age相同,會被Cache-Control覆蓋
被Cache資料,可以從DevTool看到 from disk cache的字樣,以及max-age存活時間
如果程式調整了資料沒有改變,建議先來確定瀏覽器的狀況
參考資料:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Caching_FAQ#Cache_validation
SQL(ORACLE用) - 取得EMAIL異常資料
其他判斷就再自己加,這邊是這次有想到的一些條件
--如果有英文@,._-符號以外的資料, 搜尋出來 select id from ( select id, nvl(length(regexp_replace(contactor_email,'[a-zA-Z0-9@,._\-]','')),0) as emailLen from t_member ) where emailLen>0 --如果是null, 搜尋出來 select id from t_member where (contactor_email is null or length(TRIM(contactor_email))=0) --如果不含@, 搜尋出來 select id from t_member where contactor_email not like '%@%'
改寫的時候,遇到 java.io.IOException: Bad file descriptor 錯誤,
發現是因為InputStream沒有好好處理完就做close()了,
針對緩衝部分還是要注意一下
File thisFile= new File("file's src "); /* 1. use Files.newInputStream() Opens a file, returning an input stream to read from the file. The stream will not be buffered, and is not required to support the mark or reset methods. */ InputStream is = Files.newInputStream(thisFile.toPath());
/* 2. get byte[] */ File thisFile= new File("file's src "); InputStream thisFileIs = null; try{ ByteArrayOutputStream outStream = new ByteArrayOutputStream(); thisFileIs = new FileInputStream(thisFile); byte[] thisFileIsByte = new byte[1024]; int len = 0; while ((len = thisFileIs .read(thisFileIsByte )) != -1) { outStream.write(thisFileIsByte , 0, len); } byte[] in_b = outStream.toByteArray(); }catch(IOException e){ } finally { if(thisFileIs != null) { try{ thisFileIs.close(); }catch(IOException e) { } } }
上述等同
InputStream thisFileIs = null; try{ thisFileIs = new FileInputStream(thisFile); byte[] in_b = IOUtils.toByteArray(new FileInputStream(thisFile)); //這行 }catch(IOException e){ } finally { if(thisFileIs != null) { try{ thisFileIs.close(); }catch(IOException e) { } } }
最近在操作時間習慣用 Calendar (java.util.Calendar)
https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html
//--
Calendar now = Calendar.getInstance(); //初始取得現在時間 //Get DATA int month = now.get(Calendar.MONTH) + 1; //取月份 - 月份是從0開始,+1成為一般人了解的月份 //Set DATA now.set(Calendar.MONTH, 0); //設定時間至指定月份(1月) now.set(Calendar.DAY_OF_MONTH, 1); //設定時間至1個月的第幾天(1日) //Calculation DATA now.add(Calendar.MONTH, 7); //加減月份(加7個月) now.add(Calendar.MONTH, -7); //加減月份(減7個月) //時間設為一天的最後一秒 public Calendar setDayTimeToLastSec(Calendar calendar) { calendar.set(11, 23); calendar.set(12, 59); calendar.set(13, 59); calendar.set(14, 999); return calendar; } //時間設為一天的開始 public Calendar setDayTimeToFirSec(Calendar calendar) { calendar.set(11, 0); calendar.set(12, 0); calendar.set(13, 0); calendar.set(14, 0); return calendar; } //上個月的最後一天 public Calendar getLMLD() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); //設為這個月第一天 cal.add(Calendar.DATE, -1); //倒回一天 = 上個月最後一天 return cal; //時間在此略過處理 }
再下SQL的時候使用query.setDate,發現傳入值Parameter有帶時、分、秒,但搜尋結果不如預期,查了一下發現忽略了一個很基本的東西
query.setDate 會自動過濾時分秒
條件有時分秒的時候,要使用query.setTimestamp
另外:java.sql.Date是有日期。java.util.Date包含時間部分的
寫HQL的時候做運算發生傳回型態的錯誤
SELECT (round((PRD.Price-PRD.Cost)/PRD.Price, 3)*100) AS profit FROM product PRD
HQL大概是上面這樣,然後回報下方問題。查了一下 應該是
「BigDecimal調用時,當傳入值的小數位數 大於設定的BigDecimal小數位數時,報出錯誤」
這樣的問題。
java.lang.ArithmeticException: Rounding necessary at java.math.BigDecimal.commonNeedIncrement(Unknown Source) at java.math.BigDecimal.needIncrement(Unknown Source) at java.math.BigDecimal.divideAndRound(Unknown Source) at java.math.BigDecimal.setScale(Unknown Source) at java.math.BigDecimal.toBigIntegerExact(Unknown Source) at org.hibernate.type.descriptor.java.BigIntegerTypeDescriptor.wrap(BigIntegerTypeDescriptor.java:105) at org.hibernate.type.descriptor.java.BigIntegerTypeDescriptor.wrap(BigIntegerTypeDescriptor.java:36)
如果是用SQLQuery的話
.addScalar("profit", StandardBasicTypes.BIG_DECIMAL)
應該就可以了,
<nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#">Home</a></li> <li class="breadcrumb-item"><a href="#">Library</a></li> <li class="breadcrumb-item active" aria-current="page">Data</li> </ol> </nav>
<ol class="breadcrumb"> <li><a href="#">Home</a></li> <li><a href="#">Library</a></li> <li class="active">Data</li> </ol>
var jsonObj=[]; var tempPrdList=[]; tempPrdList.push("12"); tempPrdList.push("34"); tempPrdList.push("56"); for (i = 0, j = tempPrdList.length; i < j; i++) { var obj = new Object; obj.id = tempPrdList[i]; //key=id jsonObj.push(obj); } console.log(JSON.stringify(jsonObj)); //[{"id":"12"},{"id":"34"},{"id":"56"}]
java.util.Date cannot be cast to java.sql.Date
Date date=new Date(); new java.sql.Date(date.getTime()) ; https://stackoverflow.com/questions/18614836/using-setdate-in-preparedstatement
執行時產生 runtime exception ( unchecked exception ):
class selfException extends RuntimeException{ }
應受控制產生 Checked Exception :
class selfException extends Exception{ }
參考資料:https://openhome.cc/Gossip/Java/ThrowableHierarchy.html
把EXCEL資料爬出成bean
雖然好像有一些人寫了用ANNOCATION去對應BEAN的JAR檔
不過先用簡單的方式來做一次吧
重點是beanTitle 要和EXCEL資料對應到,EXCEL的一行的第一格會是beanTitle[0]
public void mainWork(){ String filePath = "feebeeApSet.xlsx"; String[] beanTitle = {"id", "type", "startDate"}; //excel欄位對應到bean的tag this.translateToBeanFromXls(filePath, TestBean.class, beanTitle); //call function } //testBean.class public class TestBean implements Serializable { private String id; private String type; private String startDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getStartDate() { return startDate; } public void setStartDate(String startDate) { this.startDate = startDate; } } public <T> List<T> translateToBeanFromXls(String filePath, Class<T> objT, String[] beanTitle) throws Exception { List<T> beanList = new LinkedList<T>(); if(StringUtils.isBlank(filePath) || objT == null || ArrayUtils.isEmpty(beanTitle)){ //data is null! }else{ FileInputStream fs = null; XSSFWorkbook workbook = null; try{ int beanTitleSize = beanTitle.length; fs = new FileInputStream(filePath); //EXCEL workbook workbook = new XSSFWorkbook(fs); //EXCEL sheet XSSFSheet sheet = workbook.getSheetAt(0); //row num int rowNum = sheet.getPhysicalNumberOfRows(); log.info(filePath + "_rowNum: " + rowNum); //總行數 int lastRowIndex = sheet.getLastRowNum(); log.info(filePath + "_lastRowNum: " + lastRowIndex); //TITLE單位格數 int titleLastCellNum = sheet.getRow(0).getLastCellNum(); log.info(filePath + "_title.lastCellNum: " + titleLastCellNum); //判斷EXCEL是否基本資料錯誤 //1.含title 最低限制為兩列 //2.TITLE的格數須與beanTitle資料相同 if (rowNum < 2) { //ERROR }else if(beanTitleSize!=titleLastCellNum){ //ERROR }else{ for(int i = 1; i <= lastRowIndex; i++) { XSSFRow row = sheet.getRow(i); //判斷該行的單元數和beanTitle數是否能相應 int thisLastCellNum = row.getLastCellNum(); if(beanTitleSize!=thisLastCellNum){ //ERROR }else{ T bean = objT.newInstance(); //處理格數 for (int j = 0; j < thisLastCellNum; j++) { XSSFCell cell = row.getCell(j); Object cellValue = null; switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: cellValue = ""; break; case XSSFCell.CELL_TYPE_STRING: cellValue = cell.getStringCellValue().trim(); break; case XSSFCell.CELL_TYPE_BOOLEAN: cellValue = cell.getBooleanCellValue(); break; case XSSFCell.CELL_TYPE_NUMERIC: short format = cell.getCellStyle().getDataFormat(); if (HSSFDateUtil.isCellDateFormatted(cell)) { Date date = cell.getDateCellValue(); DateFormat formater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); cellValue = formater.format(date); }else if(format == 14 || format == 31 || format == 57 || format == 58){ DateFormat formater = new SimpleDateFormat("yyyy-MM-dd"); Date date = DateUtil.getJavaDate(cell.getNumericCellValue()); cellValue = formater.format(date); }else if (format == 20 || format == 32) { DateFormat formater = new SimpleDateFormat("HH:mm"); Date date = DateUtil.getJavaDate(cell.getNumericCellValue()); cellValue = formater.format(date); } else{ cellValue = cell.getNumericCellValue(); } break; default: //其他格式不處理 cellValue = null; break; } if(cellValue!=null){ // 轉成bean BeanUtils.setProperty(bean, beanTitle[j], cellValue); } } beanList.add(bean); } } } }finally{ if(fs!=null){fs.close();} } } return beanList; }
STEP 1:
第一層:使用 .navbar
附加設訂:
sheet.getPhysicalNumberOfRows();
獲取有記錄的行數 (NULL列數略過不計)
sheet.getLastRowNum();
獲取最後行數,回傳值為最後行數-1 (只有一行的話回傳0)
the number of the last row contained in this sheet, zero based.
Owing to idiosyncrasies in the excel file format, if the result of calling this method is zero, you can't tell if that means there are zero rows on the sheet, or one at position zero. For that case, additionally call getPhysicalNumberOfRows() to tell if there is a row at position zero or not.
頁面有時候要增埋監聽事件,又怕被綁在物件上的事件影響時,有以下順序可以作為參考切入點
EX:
1. 連結裡埋一個onclick事件
2. 連結設為 https://www.google.com.tw/
3. 再分別設3個監聽.on()事件
<a id="testID" onclick="alert('tagOnclick');" href="https://www.google.com.tw/">
For test
</a>
$("#testID").on('click', function(event){ alert("1"); }); $("#testID").on('click', function(event){ alert("2"); }); $("#testID").on('click', function(event){ alert("3"); });
RESULT:
alert('tagOnclick');
alert('1');
alert('2);
alert('3');
location to https://www.google.com.tw/
判斷string是否是數字
NumberUtils.isNumber(string) =>將被廢棄,建議使用 isCreatable(String)
現在發布的 Class NumberUtils 底層可以看到直接轉用 isCreatable(String)了
/** * NumberUtils.isNumber Deprecated. * This feature will be removed in Lang 4.0, use isCreatable(String) instead */ NumberUtils.isNumber("123"); //true NumberUtils.isNumber("qwe"); //false NumberUtils.isCreatable("123"); //true NumberUtils.isCreatable("qwe"); //false NumberUtils.isCreatable(""); //false NumberUtils.isCreatable(" "); //false NumberUtils.isCreatable(null); //false