- 投資沒有時間點的限制,也沒有所謂的最佳投資時間點,只要有錢就應該盡早投資
- 緊急預備金至少要準備六個月,才把其他錢拿來投資
- 只有承擔風險才能有更多的報酬,沒有高報酬又低風險的商品,你該學習的是如何有效控制風險,而不是去逃避風險
- 有錢人才不需要買保險,因為他們所擁有的財富足以面對他們可能遇到的意外、健康等風險。越沒錢的人越需要保險,有了保險,就不必恐懼未來。
- 你的投資報酬率要戰勝通貨膨脹率,荷包裡的錢才不會越變越薄。過去20年來,台灣每年的通貨膨脹率約2.2%
- 在做投資判斷的時候,不能只看累積報酬率,必須換算成年化報酬率,對投資績效評比才有意義。投資報酬率必須與『投資期間』相連結,才有意義
- 利率高低會影響投資動向,利率調升,有部分不願意冒風險的投資人,會將投資股票的錢轉到銀行定存;當利率調降時,投資者因為無法滿足銀行提供的報酬率,就會解除定存,將資金移到報酬率較高的投資標的
- 72法則可以讓你根據報酬率簡單算出,需要多少年,財富就能成長一倍。例如把10萬元投資在年報酬15%的商品,只要72 / 15 = 4.8年,就可以變成20萬元
- 指數代表一個國家、一個區域貨一個產業區塊隨著時間的變化情形。投資指數不會有基金經理人是否適任的問題,也不用考慮個別股票的漲跌,只要該地區或區塊的指數成長,投資代表該地區的ETF也就一定會賺,投資指數型基金,道理就是這麼簡單。
- 如果你想要了解全球的股市狀況,就去觀察MSCI World Index;想要了解美國股市,就去看S&P 500;如果想了解中國地區,可以去研究滬深300指數(CIS 300)
- 若指數波段型態屬持續向上,代表適合長期投資;有些地區的指數雖然是上下波動,或看不到向上趨勢,則只適合波段操作
- 以投資穩定性來說,投資一個區域要比投資單音國家相對平穩,雖然投資一個區域的投資報酬率會比投資單一國家來得低,但相對的不用承擔較大的波動風險
- 台灣50 ETF本身就是追蹤指數,績效幾乎等於大盤,而且沒有個別因素需要考慮,也就是不用擔心遇到地雷股
- 當股市重挫時,就要勇於啟動定期定額的攤平策略,利用微笑曲線來獲利;但是不建議長期操作,請一定要注意
- 要投資定期定額基金,最重要的前提是,一定要選擇具有長期往上趨勢的投資標的,選到趨勢往下的基金,即使是定期定額,也是會虧錢。定期定額無法改變往下或往上的趨勢。
- 定期定額的攤平效用會隨著時間的拉長而出現鈍化的現象,由於資產累積會隨著定期投入而增大,到了一定時候並然累積一定數量的金額,如果此時遇到空頭市場,股市往下跌,資產淨值也會跟著往下跌,這時每月在投入金額比起累計金額規模相對小,所以攤平小過有限。要解決這個問題,就是要隨著時間增加投入金額的比例
- 買定存股最好的時機是在股市空頭的時候,因為買定存股的主要目的是配息,不是要賺短期波段,所以空頭時期買進並無不妥,而且買到的價格越低,殖利率就會越高,獲利就會越好
- 「債券」是一個國家或企業為了籌措長期資金所發行的一種債權憑證。國家發行就叫國家公債,企業發行就叫公司債,目的都是向民眾借錢,也就是一般所謂的借據。買公債,就是把錢借給國家,收取債券上的票息。
- 購買海外基金一定會遇到匯率風險,若要克服匯率風險,有兩個因素要考慮:一個是報酬率越高,可以對抗的匯率風險就越大;另外一個是投資時間越長,匯率因素就越淡化
- 選擇債券型基金,一定要根據自己期望的投資報酬率與可以忍受的風險,找出最適合自己的投資標的
- 貸款利率愈低,貸款期限愈短,就是愈好的貸款方案
- 評估轉貸時,別忘了還有轉貸所衍生的費用要算進去
- 貸款買房來投資,貸款比例越高,報酬率就越高
- 財務槓桿式雙面刃,可以提昇報酬率,也可能會放大損失。如果貸款利率提高,或是租金收入不如預期,甚至出現虧損時,財務槓桿就會擴大損失
- 房地產投資特別是合作財務槓桿操作,但仍要注意收入與利息的關係
Total Pageviews
2015/07/01
[閱讀筆記] 第一次領薪水就該懂的理財方法
Labels:
Investment,
Reading
2015/06/30
2015/06/27
[Programming] 不被誤解的名稱
最近閱讀了易讀程式之美一書,在不被誤解的名稱此章節提到幾個重點
Example
1. 對於邊界的極值而言,最清楚的方式是在名稱前面加上max_或min_。以切字串為例,即長度第15個字以後以...表示,如"撰寫程式時,應該將讀者理解所需的時間降到最短"此段字串要回傳"撰寫程式時,應該將讀者理解所需..."
如在main method裡面分別呼叫clip與truncate兩個methods
以下是clip method的第二個parameter的命名
以下是truncate method的命名,改成用maxLength,相較於前者,較為明確、清楚
2. 加上is / has / can / should 可以讓boolean value更加明確
若將checkPassword改成如下,意義會更加直覺
- 反覆思考名稱,自問別人會怎麼解釋這個名稱
- 對於邊界的極值而言,最清楚的方式是在名稱前面加上max_或min_
- 選擇boolean變數或回傳booleab值的函數名稱時,必須確保能清楚表示true / false的意義
- 一般來說,加上is / has / can / should 可以讓boolean value更加明確
- 避免在名稱中使用否定描述,如disableSSL,改用useSSL會比較容易閱讀且簡短
- 最好的名稱是最不容易被誤用的名稱,閱讀程式碼的人能夠清楚了解撰寫程式的人的意圖。不幸的是,許多英文單字在程式碼都會有兩種以上的解釋,如filter、length以及limit
- 在決定名稱前,要從反向思考,想像可能造成的誤解,最好的名稱能夠盡量避免誤會
- 對於定義數值的上下限,max與min是很有幫助的prefix;對於閉區間,first與last也是十分合適的prefix;對於半開放區間,begin與end是符合使用慣例的好選擇
- 注意使用者對特定單字的預期,如使用者會認為get與size是lightweight accessor
Example
1. 對於邊界的極值而言,最清楚的方式是在名稱前面加上max_或min_。以切字串為例,即長度第15個字以後以...表示,如"撰寫程式時,應該將讀者理解所需的時間降到最短"此段字串要回傳"撰寫程式時,應該將讀者理解所需..."
如在main method裡面分別呼叫clip與truncate兩個methods
1 2 3 | String str = "撰寫程式時,應該將讀者理解所需的時間降到最短"; test.clip(str, 15); test.truncate(str, 15); |
以下是clip method的第二個parameter的命名
1 2 3 | public String clip(String text, int length) { return text.substring(0, length).concat("..."); } |
以下是truncate method的命名,改成用maxLength,相較於前者,較為明確、清楚
1 2 3 4 | // 改成maxLength,會更加清楚明瞭 public String truncate(String text, int maxLength) { return text.substring(0, maxLength).concat("..."); } |
2. 加上is / has / can / should 可以讓boolean value更加明確
1 2 3 4 5 | public Boolean authenticate(User user) { // do authentication, if failed Boolean checkPassword = Boolean.FALSE; return checkPassword; } |
若將checkPassword改成如下,意義會更加直覺
1 2 3 4 5 | public Boolean authenticate(User user) { // do authentication, if failed Boolean userIsAuthnticated = Boolean.FALSE; return userIsAuthnticated; } |
Labels:
Programming
2015/06/24
SQL Developer 常用 hotkeys
- ctrl-enter : executes the current statement(s)
- F5 : executes the current code as a script (think SQL*Plus)
- ctrl-space : invokes code insight on demand
- ctrl-Up/Dn : replaces worksheet with previous/next SQL from SQL History
- ctrl-shift+Up/Dn : same as above but appends instead of replaces
- shift+F4 : opens a Describe window for current object at cursor
- ctrl+F7 : format SQL
- ctrl+/ : toggles line commenting
- ctrl+e : incremental search
Reference
[1] http://www.thatjeffsmith.com/archive/2012/11/keyboard-shortcuts-in-oracle-sql-developer/
Labels:
SQLDeveloper
2015/06/22
[egit] Fail to change branch from master to another
Problem
I want to change branch from master to another branch (i.e. WebcommUpload0618 )
But it failed to change branch via egit.
As I change branch again, but it show this error message:
The problem is there are some source belong to another branch but copy to master, because egit fail to do rollback.
So it added some untracked files which belong to WebcommUpload0618 branch not master branch
Solution
1. use git status to list untracked files
2. use git clean -n to list the files which will be removed
3. use git clean -f to remove files
After cleaning untracking files, then I can change granch succesfully
Reference
[1] https://ihower.tw/git/basic.html
I want to change branch from master to another branch (i.e. WebcommUpload0618 )
But it failed to change branch via egit.
As I change branch again, but it show this error message:
The problem is there are some source belong to another branch but copy to master, because egit fail to do rollback.
So it added some untracked files which belong to WebcommUpload0618 branch not master branch
Solution
1. use git status to list untracked files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | albert@ALBERT-PC /D/git/dbm (master) $ git status On branch master Your branch is up-to-date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java nothing added to commit but untracked files present (use "git add" to track) |
2. use git clean -n to list the files which will be removed
1 2 3 4 5 6 7 8 9 | albert@ALBERT-PC /D/git/dbm (master) $ git clean -n Would remove dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java Would remove dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java Would remove dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java |
3. use git clean -f to remove files
1 2 3 4 5 6 7 8 9 | albert@ALBERT-PC /D/git/dbm (master) $ git clean -f Removing dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java Removing dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java Removing dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java |
After cleaning untracking files, then I can change granch succesfully
Reference
[1] https://ihower.tw/git/basic.html
Labels:
Git
2015/06/21
經常項目(recurrent items) vs 非經常項目(nonrecurrent items)
Security Analysis 一書中提到,依據個人情感、情緒所做的交易,通常都是錯誤的投資行為。你應該仔細去研讀投資標的的income statement (損益表)與balance sheet (資產負債表)。
當你在研讀income statement (損益表)時,要注意到經常項目(recurrent items)與非經常項目(nonrecurrent items)的區別。經常項目(recurrent items)代表是持續性的獲得或損失(或稱之為營業內),非經常項目(nonrecurrent items)代表偶然性的獲得或損失(或稱之為營業外)
舉個例子來說,以下圈選起來的項目,就屬於經常項目(recurrent items)
以下圈選起來的項目,屬於非經常項目(nonrecurrent items)
以某間公司作為另外一個例子,2013的EPS突然從去年的1.47成長到2.63,但是細究其利潤結構,發現原來是2013年有出現鉅額的非經常項目獲利所導致,並非本業有大幅成長
由以上例子可以得知,在研究公司的獲利能力時,不僅要看公司的利潤金額,還要看公司的利潤結構,區分利潤中哪些是可以持續獲得的,哪些是偶然獲得的。要把數字往下drill down分析,而不是只看表面的數字
Reference
[1] http://www.cmoney.tw/finance/f00041.aspx?s=2412
當你在研讀income statement (損益表)時,要注意到經常項目(recurrent items)與非經常項目(nonrecurrent items)的區別。經常項目(recurrent items)代表是持續性的獲得或損失(或稱之為營業內),非經常項目(nonrecurrent items)代表偶然性的獲得或損失(或稱之為營業外)
舉個例子來說,以下圈選起來的項目,就屬於經常項目(recurrent items)
以下圈選起來的項目,屬於非經常項目(nonrecurrent items)
以某間公司作為另外一個例子,2013的EPS突然從去年的1.47成長到2.63,但是細究其利潤結構,發現原來是2013年有出現鉅額的非經常項目獲利所導致,並非本業有大幅成長
由以上例子可以得知,在研究公司的獲利能力時,不僅要看公司的利潤金額,還要看公司的利潤結構,區分利潤中哪些是可以持續獲得的,哪些是偶然獲得的。要把數字往下drill down分析,而不是只看表面的數字
Reference
[1] http://www.cmoney.tw/finance/f00041.aspx?s=2412
Labels:
Investment
[Programming] 富含資訊的名稱
最近閱讀了易讀程式之美一書,在富含資訊的名稱此章節提到幾個重點
Example
1. 避免使用rtnVal,應給予有意義的名稱
以下是原本的寫法
以下是修改後的寫法,讓名稱具有意義
2. 避免使用tmp
以下是原本的寫法
以下是修改後的寫法,userInfo比tmp傳達更多資訊
3. for-loop避免用 i, j, k 這樣的變數,尤其在nested loop你會改不清楚誰是誰
以下是原本的寫法
以下是修改後的寫法
- 程式碼應該易於理解
- 撰寫程式時,應該將讀者理解所需的時間降到最短
- 雖然減少程式碼數量是個很好的目標,但縮短理解時間更加重要
- 實務上,讓程式碼易於了解,往往也會產生良好的架構且易於測試
- 無論是重新命名變數、函數或類別,基本原則大同小異。名稱可視為簡短的註解,即使空間有限,透過選擇好的名稱就能包含許多資訊
- retval這類名稱不包含任何有意的資訊,只能代表return value,應該使用能夠說明便數值意義的名稱
- tmp這樣的名稱,只適用於變數生命週期很短,且作為暫存用途的變數
- 變數名稱不宜太長,名稱愈長就愈不容易記住,也會佔用更多畫面空間,甚至造成額外的自動換行
Example
1. 避免使用rtnVal,應給予有意義的名稱
以下是原本的寫法
1 2 3 4 5 | Double rtnVal = 0d; for (int i = 0; i < input; i++) { rtnVal += i * i; } return Math.sqrt(rtnVal); |
以下是修改後的寫法,讓名稱具有意義
1 2 3 4 5 | Double sumSquares = 0d; for (int i = 0; i < input; i++) { sumSquares += i * i; } return Math.sqrt(sumSquares); |
2. 避免使用tmp
以下是原本的寫法
1 2 3 4 5 | public String demoForBadExample2(User user) { String tmp = user.getName(); tmp += " " + user.getEmail(); return tmp; } |
以下是修改後的寫法,userInfo比tmp傳達更多資訊
1 2 3 4 5 | public String demoForGoodEaxmple2(User user) { String userInfo = user.getName(); userInfo += " " + user.getEmail(); return userInfo; } |
3. for-loop避免用 i, j, k 這樣的變數,尤其在nested loop你會改不清楚誰是誰
以下是原本的寫法
1 2 3 4 5 | public void demoForBadExample3(List<User> users) { for (int i = 0; i < users.size(); i++) { System.out.println(users.get(i).toString()); } } |
以下是修改後的寫法
1 2 3 4 5 | public void demoForGoodExample3(List<User> users) { for (int user_i = 0; user_i < users.size(); user_i++) { System.out.println(users.get(user_i).toString()); } } |
Labels:
Programming
2015/06/18
[Microsoft Outlook] reading pane had been disabled
Problem
One day I found out my reading panel had been disabled in Microsoft Outlook.
It is very inconvenient for me, because I cannot preview my email anymore.
Root Cause
Because of corporate's security policy, it disabled all employees' reading panel in everyone's Microsoft Outlook.
Solution
1. Start => type in "regedit" => enter
2. Find the registry : HKEY_CURRENT_USER\Software\Policies\Microsoft\office\14.0\Outlook\options
3. Change the value of property, disablereadingpane, from 1 to 0
4. Restart Microsoft Outlook
Reference
[1] http://www.slipstick.com/outlook/rules/disable-outlooks-reading-pane/
One day I found out my reading panel had been disabled in Microsoft Outlook.
It is very inconvenient for me, because I cannot preview my email anymore.
Root Cause
Because of corporate's security policy, it disabled all employees' reading panel in everyone's Microsoft Outlook.
Solution
1. Start => type in "regedit" => enter
2. Find the registry : HKEY_CURRENT_USER\Software\Policies\Microsoft\office\14.0\Outlook\options
3. Change the value of property, disablereadingpane, from 1 to 0
4. Restart Microsoft Outlook
Reference
[1] http://www.slipstick.com/outlook/rules/disable-outlooks-reading-pane/
Labels:
Microsoft Office,
MicrosoftWindows
JoSQL (SQL for Java Objects)
Requirement
If I have a Java collection as bellows:
If I would like to utilize SQL statements to do search, which tool can help me?
Solution
JoSQL (SQL for Java Objects) provides the ability for a developer to apply a SQL statement to a collection of Java Objects.
JoSQL provides the ability to search, order and group ANY Java objects and should be applied when you want to perform SQL-like queries on a collection of Java Objects.
Prerequisite
Configure the two jar files in your classpath:
Example
In this example, it will demonstrate:
Console:
Reference
[1] http://josql.sourceforge.net/
If I have a Java collection as bellows:
1 2 3 | Employee [empNo=1, name=Albert, gender=M, onBoardDate=Thu Feb 05 15:20:44 CST 2009] Employee [empNo=2, name=Mandy, gender=null, onBoardDate=Fri Mar 05 15:20:44 CST 2010] Employee [empNo=3, name=Verio, gender=M, onBoardDate=Thu Feb 05 15:20:44 CST 2009] |
If I would like to utilize SQL statements to do search, which tool can help me?
Solution
JoSQL (SQL for Java Objects) provides the ability for a developer to apply a SQL statement to a collection of Java Objects.
JoSQL provides the ability to search, order and group ANY Java objects and should be applied when you want to perform SQL-like queries on a collection of Java Objects.
Prerequisite
Configure the two jar files in your classpath:
Example
In this example, it will demonstrate:
- find all employee objects
- find all male employee objects
- find employee objects which named "Mandy"
- find all male employee object which onBoardDate between 2009/01/01 to 2009/12/31
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | package test; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import org.josql.Query; import org.josql.QueryExecutionException; import org.josql.QueryParseException; import org.josql.QueryResults; import test.vo.Employee; /** * The Class JoSqlTest. */ public class JoSqlTest { private List<Employee> employees = new ArrayList<Employee>(); /** * The main method. * * @param args * the arguments */ public static void main(String[] args) { JoSqlTest test = new JoSqlTest(); test.setupData(); test.findAllEmployees(); test.findAllMaleEmployees(); test.findByEmployeeName("Mandy"); test.findByGenderAndOnBoardDate("M", "2009/01/01", "2009/12/31"); } /** * Select all employees. */ public void findAllEmployees() { System.out.println("\n * find all employees"); String sql = "select * from test.vo.Employee"; // Create a new Query. Query query = new Query(); try { // Parse the SQL you are going to use. query.parse(sql); // Execute the query. QueryResults qr = query.execute(employees); // Get the query results. List<Employee> result = qr.getResults(); // Print search research for (Employee employee : result) { System.out.println(employee.toString()); } } catch (QueryParseException e) { throw new RuntimeException(e); } catch (QueryExecutionException e) { throw new RuntimeException(e); } } /** * Select all male employees. */ public void findAllMaleEmployees() { System.out.println("\n * find all male employees"); String sql = "select * from test.vo.Employee where gender = :gender"; // Create a new Query. Query query = new Query(); try { // Parse the SQL you are going to use. query.parse(sql); // set variable query.setVariable("gender", "M"); // Execute the query. QueryResults queryResults = query.execute(employees); // Get the query results. List<Employee> result = queryResults.getResults(); // Print search research for (Employee employee : result) { System.out.println(employee.toString()); } } catch (QueryParseException e) { throw new RuntimeException(e); } catch (QueryExecutionException e) { throw new RuntimeException(e); } } /** * Find by employee name. * * @param name * the name */ public void findByEmployeeName(String name) { System.out.println("\n * find by employee name"); String sql = "select * from test.vo.Employee where name = :name"; // Create a new Query. Query query = new Query(); try { // Parse the SQL you are going to use. query.parse(sql); // set variable query.setVariable("name", name); // Execute the query. QueryResults queryResults = query.execute(employees); // Get the query results. List<Employee> result = queryResults.getResults(); // Print search research for (Employee employee : result) { System.out.println(employee.toString()); } } catch (QueryParseException e) { throw new RuntimeException(e); } catch (QueryExecutionException e) { throw new RuntimeException(e); } } /** * Find by gender and on board date. * * @param gender * the gender * @param fromDate * the from date * @param toDate * the to date */ public void findByGenderAndOnBoardDate(String gender, String fromDate, String toDate) { System.out.println("\n * find By Gender And OnBoardDate"); String sql = "select * from test.vo.Employee where gender = :gender " + " and onBoardDate between :fromDate and :toDate "; // Create a new Query. Query query = new Query(); try { // Parse the SQL you are going to use. query.parse(sql); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); // set variable query.setVariable("gender", gender); query.setVariable("fromDate", dateFormat.parse(fromDate)); query.setVariable("toDate", dateFormat.parse(toDate)); // Execute the query. QueryResults queryResults = query.execute(employees); // Get the query results. List<Employee> result = queryResults.getResults(); // Print search research for (Employee employee : result) { System.out.println(employee.toString()); } } catch (QueryParseException e) { throw new RuntimeException(e); } catch (QueryExecutionException e) { throw new RuntimeException(e); } catch (ParseException e) { throw new RuntimeException(e); } } /** * Setup data. */ public void setupData() { System.out.println("\n * setup data"); Employee albert = new Employee(); albert.setEmpNo(1L); albert.setName("Albert"); albert.setGender("M"); Calendar cal1 = Calendar.getInstance(); cal1.set(Calendar.YEAR, 2009); cal1.set(Calendar.MONTH, 1); cal1.set(Calendar.DATE, 5); albert.setOnBoardDate(cal1.getTime()); Employee mandy = new Employee(); mandy.setEmpNo(2L); mandy.setName("Mandy"); Calendar cal2 = Calendar.getInstance(); cal2.set(Calendar.YEAR, 2010); cal2.set(Calendar.MONTH, 2); cal2.set(Calendar.DATE, 5); mandy.setOnBoardDate(cal2.getTime()); Employee verio = new Employee(); verio.setEmpNo(3L); verio.setName("Verio"); verio.setGender("M"); Calendar cal3 = Calendar.getInstance(); cal3.set(Calendar.YEAR, 2009); cal3.set(Calendar.MONTH, 8); cal3.set(Calendar.DATE, 10); verio.setOnBoardDate(cal1.getTime()); employees.add(albert); employees.add(mandy); employees.add(verio); } } |
Console:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | * setup data * find all employees Employee [empNo=1, name=Albert, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] Employee [empNo=2, name=Mandy, gender=null, onBoardDate=Fri Mar 05 16:00:48 CST 2010] Employee [empNo=3, name=Verio, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] * find all male employees Employee [empNo=1, name=Albert, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] Employee [empNo=3, name=Verio, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] * find by employee name Employee [empNo=2, name=Mandy, gender=null, onBoardDate=Fri Mar 05 16:00:48 CST 2010] * find By Gender And OnBoardDate Employee [empNo=1, name=Albert, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] Employee [empNo=3, name=Verio, gender=M, onBoardDate=Thu Feb 05 16:00:48 CST 2009] |
Reference
[1] http://josql.sourceforge.net/
Labels:
Programming
Subscribe to:
Posts (Atom)