Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
65c08982
Commit
65c08982
authored
Oct 14, 2020
by
pengfei_liu
Browse files
#首页获取前6个月日期代码调整
parent
8d3d0314
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/controller/DepotItemController.java
View file @
65c08982
...
@@ -706,10 +706,7 @@ public class DepotItemController {
...
@@ -706,10 +706,7 @@ public class DepotItemController {
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
String
message
=
"成功"
;
String
message
=
"成功"
;
try
{
try
{
Date
date
=
new
Date
();
List
<
String
>
list
=
Tools
.
getLastMonths
(
6
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM"
);
String
dateString
=
formatter
.
format
(
date
);
List
<
String
>
list
=
Tools
.
getSixMonth
(
dateString
);
map
.
put
(
"monthList"
,
list
);
map
.
put
(
"monthList"
,
list
);
List
<
BigDecimal
>
buyPriceList
=
new
ArrayList
<
BigDecimal
>();
List
<
BigDecimal
>
buyPriceList
=
new
ArrayList
<
BigDecimal
>();
for
(
String
month:
list
)
{
for
(
String
month:
list
)
{
...
...
src/main/java/com/jsh/erp/utils/Tools.java
View file @
65c08982
...
@@ -155,6 +155,27 @@ public class Tools {
...
@@ -155,6 +155,27 @@ public class Tools {
return
new
SimpleDateFormat
(
"yyyy-MM"
).
format
(
cal
.
getTime
());
return
new
SimpleDateFormat
(
"yyyy-MM"
).
format
(
cal
.
getTime
());
}
}
/**
* 获取当前月份的前6个月(含当前月)
* @param size 月数
* @return
*/
public
static
List
<
String
>
getLastMonths
(
int
size
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM"
);
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
new
Date
());
List
<
String
>
list
=
new
ArrayList
(
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
c
.
setTime
(
new
Date
());
c
.
add
(
Calendar
.
MONTH
,
-
i
);
Date
m
=
c
.
getTime
();
list
.
add
(
sdf
.
format
(
m
));
}
Collections
.
reverse
(
list
);
return
list
;
}
/**
/**
* 获取当前月份的前6个月(含当前月)
* 获取当前月份的前6个月(含当前月)
* @param date
* @param date
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment