| | |
| | | |
| | | import android.annotation.SuppressLint; |
| | | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.sdk.link.core.utils.LanguageUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | |
| | | public class TimeUtils { |
| | | |
| | | /** |
| | | * 获取分钟 |
| | | * |
| | | * @param timestamp 时间戳 |
| | | * @return - |
| | | */ |
| | | public static String getMinuteTime(long timestamp) { |
| | | try { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("mm", Locale.ENGLISH); |
| | | Date date = new Date(timestamp); |
| | | return dateFormat.format(date); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 时间戳转时间(格式:yyyy-MM-dd) |
| | | * |
| | | * @param timestamp 时间戳 |
| | | * @return - |
| | | */ |
| | | public static String getDateTimestamp(long timestamp) { |
| | | try { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd ", Locale.ENGLISH); |
| | | Date date = new Date(timestamp); |
| | | return dateFormat.format(date); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 时间戳转时间(格式:yyyy-MM-dd HH:mm:ss) |
| | | * |
| | | * @param timestamp 时间戳 |
| | |
| | | */ |
| | | public static String getTimeFromTimestamp(long timestamp) { |
| | | try { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); |
| | | String pattern = "yyyy-MM-dd HH:mm"; |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.en)) { |
| | | pattern = "dd-MM-yyyy HH:mm"; |
| | | } |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH); |
| | | Date date = new Date(timestamp); |
| | | return dateFormat.format(date); |
| | | } catch (Exception e) { |