Ideas:
Get the start and end dates of the current quarter, pushing forward 3 months, the start and end dates of the previous quarter, on the basis of the current date
/** * @param flag true: start date; false: End date * @return/public static String Getlastquartertime (Boolean flag) {
SimpleDateFormat shortsdf = new SimpleDateFormat ("Yyyy-mm-dd");
SimpleDateFormat longsdf = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
String resultdate= "";
Date now = null;
try {Calendar calendar = calendar.getinstance ();
int currentmonth = Calendar.get (calendar.month) + 1; true: start date; false: End date if (flag) {if (currentmonth >= 1 && currentmonth <= 3) Calenda
R.set (calendar.month, 0);
else if (currentmonth >= 4 && currentmonth <= 6) Calendar.set (Calendar.month, 3);
else if (currentmonth >= 7 && currentmonth <= 9) Calendar.set (Calendar.month, 6);
else if (currentmonth >= && currentmonth <=) calendar.set (Calendar.month, 9);
Calendar.set (calendar.date, 1); now = LonGsdf.parse (Shortsdf.format (Calendar.gettime ()) + "00:00:00");
}else{if (currentmonth >= 1 && currentmonth <= 3) {Calendar.set (Calendar.month, 2);
Calendar.set (Calendar.date, 31);
else if (currentmonth >= 4 && currentmonth <= 6) {Calendar.set (Calendar.month, 5);
Calendar.set (Calendar.date, 30);
else if (currentmonth >= 7 && currentmonth <= 9) {Calendar.set (calendar.month, 8);
Calendar.set (Calendar.date, 30);
else if (currentmonth >= && currentmonth <=) {calendar.set (calendar.month, 11);
Calendar.set (Calendar.date, 31);
now = Longsdf.parse (Shortsdf.format (Calendar.gettime ()) + "23:59:59");
Calendar.settime (now);//Set Date Calendar.add (Calendar.month,-3);
Resultdate = Longsdf.format (Calendar.gettime ());
catch (Exception e) {; } rEturn resultdate;
}