Code highlighting produced by Actipro CodeHighlighter (freeware) |
|
--> 1. packagecom.snail.gequ.action; |
2. |
3. importjava.util.Calendar; |
4. importjava.util.Date; |
5. |
6. importorg.apache.log4j.Logger; |
7. importorg.hibernate.criterion.Expression; |
8. importorg.hibernate.criterion.Projections; |
9. |
10. importcom.snail.commons.basedao.IBaseDAO; |
11. importcom.snail.component.beans.Gequ; |
12. importcom.snail.component.beans.Gequzhuanji; |
13. importcom.snail.component.beans.Huiyuan; |
14. importcom.snail.component.beans.Renqirecord; |
15. |
16. publicclassRenQiRecordUtil { |
17. |
18. privatestaticfinallongserialVersionUID =3193922028309094171L; |
19. privatefinalstaticLogger logger =Logger |
20. .getLogger(RenQiRecordUtil.class); |
21. |
22. |
23. |
24. |
25. protectedInteger getMonthOfThisYear() { |
26. Calendar cal =Calendar.getInstance(); |
27. cal.setTime(newDate()); |
28. returncal.get(Calendar.MONTH) +1; |
29. |
30. } |
31. |
32. protectedDate getTimeByMonth(Integer month) { |
33. Calendar cal =Calendar.getInstance(); |
34. cal.setTime(newDate()); |
35. cal.set(Calendar.MONTH, month -1); |
36. returncal.getTime(); |
37. } |
38. |
39. protectedDate getMonthBegin(Date date) { |
40. Calendar cal =Calendar.getInstance(); |
41. cal.setTime(date); |
42. cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 1, 0, 0, 0); |
43. returncal.getTime(); |
44. } |
45. |
46. protectedDate getMonthEnd(Date date) { |
47. Calendar cal =Calendar.getInstance(); |
48. cal.setTime(date); |
49. cal |
50. .set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) +1, 1, 0, |
51. 0, 0); |
52. cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) -1); |
53. |
54. returncal.getTime(); |
55. } |
56. protectedDate getWeekBegin(Date date) { |
57. Calendar cal =Calendar.getInstance(); |
58. cal.setTime(date); |
59. Date mm=nDaysAgo(cal.get(Calendar.DAY_OF_WEEK)-2,date); |
60. returngetDayBegin(mm); |
61. } |
62. |
63. protectedDate getWeekEnd(Date date) { |
64. Calendar cal =Calendar.getInstance(); |
65. cal.setTime(date); |
66. Date mm=nDaysAfter(cal.get(8-Calendar.DAY_OF_WEEK),date); |
67. returngetDayEnd(mm); |
68. |
69. } |
70. protectedDate nDaysAfter(intn,Date date) { |
71. Calendar cal =Calendar.getInstance(); |
72. cal.setTime(date); |
73. cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH)+n); |
74. returncal.getTime(); |
75. } |
76. |
77. protectedDate getDayBegin(Date date) { |
78. Calendar cal =Calendar.getInstance(); |
79. cal.setTime(date); |
80. cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); |
81. returncal.getTime(); |
82. } |
83. |
84. protectedDate getDayEnd(Date date) { |
85. Calendar cal =Calendar.getInstance(); |
86. cal.setTime(date); |
87. cal |
88. .set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH)+1, 0, |
89. 0, 0); |
90. cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) -1); |
91. |
92. returncal.getTime(); |
93. } |
94. |
95. protectedDate nMonthsAgo(Integer n,Date date) { |
96. Calendar cal =Calendar.getInstance(); |
97. cal.setTime(date); |
98. cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) -n); |
99. returncal.getTime(); |
100. } |
101. protectedDate nDaysAgo(Integer n,Date date) { |
102. Calendar cal =Calendar.getInstance(); |
103. cal.setTime(date); |
104. cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) -n); |
105. returncal.getTime(); |
106. } |
107. publicRenQiRecordUtil() { |
108. //TODO Auto-generated constructor stub 109. } |
110. |
111. |
112. } |
|