| | |
| | | import android.text.TextUtils; |
| | | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.enums.TimeType; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.home.HomePageFragment; |
| | | import com.hdl.sdk.link.core.utils.LanguageUtils; |
| | |
| | | * @param dayMonthYearToAdd 天数(日,月,年) |
| | | * @return 日历 |
| | | */ |
| | | public static String addDayMonthYearToDate(Calendar date, int dayMonthYearToAdd, String dateFormat, HomePageFragment.TimeType timeType) { |
| | | public static String addDayMonthYearToDate(Calendar date, int dayMonthYearToAdd, String dateFormat, String timeType) { |
| | | Calendar newDate = (Calendar) date.clone(); |
| | | if (timeType == HomePageFragment.TimeType.day) { |
| | | newDate.add(Calendar.DAY_OF_MONTH, dayMonthYearToAdd); |
| | | } else if (timeType == HomePageFragment.TimeType.month) { |
| | | newDate.add(Calendar.MONTH, dayMonthYearToAdd); |
| | | } else if (timeType == HomePageFragment.TimeType.year || timeType == HomePageFragment.TimeType.lifecycle) { |
| | | newDate.add(Calendar.YEAR, dayMonthYearToAdd); |
| | | switch (timeType) { |
| | | case TimeType.day: { |
| | | newDate.add(Calendar.DAY_OF_MONTH, dayMonthYearToAdd); |
| | | } |
| | | break; |
| | | case TimeType.month: { |
| | | newDate.add(Calendar.MONTH, dayMonthYearToAdd); |
| | | } |
| | | break; |
| | | case TimeType.year: |
| | | case TimeType.all: { |
| | | newDate.add(Calendar.YEAR, dayMonthYearToAdd); |
| | | } |
| | | break; |
| | | } |
| | | return calendarToString(newDate, dateFormat); |
| | | } |
| | |
| | | * @param dayMonthYearToSubtract 天数 |
| | | * @return 日历 |
| | | */ |
| | | public static String subtractDayMonthYearFromDate(Calendar date, int dayMonthYearToSubtract, String dateFormat, HomePageFragment.TimeType timeType) { |
| | | public static String subtractDayMonthYearFromDate(Calendar date, int dayMonthYearToSubtract, String dateFormat, String timeType) { |
| | | Calendar newDate = (Calendar) date.clone(); |
| | | if (timeType == HomePageFragment.TimeType.day) { |
| | | newDate.add(Calendar.DAY_OF_MONTH, -dayMonthYearToSubtract); |
| | | } else if (timeType == HomePageFragment.TimeType.month) { |
| | | newDate.add(Calendar.MONTH, -dayMonthYearToSubtract); |
| | | } else if (timeType == HomePageFragment.TimeType.year) { |
| | | newDate.add(Calendar.YEAR, -dayMonthYearToSubtract); |
| | | switch (timeType) { |
| | | case TimeType.day: { |
| | | newDate.add(Calendar.DAY_OF_MONTH, -dayMonthYearToSubtract); |
| | | } |
| | | break; |
| | | case TimeType.month: { |
| | | newDate.add(Calendar.MONTH, -dayMonthYearToSubtract); |
| | | } |
| | | break; |
| | | case TimeType.year: |
| | | case TimeType.all: { |
| | | newDate.add(Calendar.YEAR, -dayMonthYearToSubtract); |
| | | } |
| | | break; |
| | | } |
| | | return calendarToString(newDate, dateFormat); |
| | | } |