From 03f9370b85d930bd232f72721e826b5875f898cb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 16 五月 2020 13:52:58 +0800 Subject: [PATCH] 用户登录后要验证电话号码是否已经绑定 --- fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 87 insertions(+), 2 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java index bacb205..e419487 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java @@ -86,11 +86,61 @@ date = sdf.parse(st); return date.getTime(); } catch (Exception e) { - // e.printStackTrace(); + e.printStackTrace(); return 0; } } - + + public static Date parseYYYYMM(String st) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + try { + return sdf.parse(st); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static Date parseYYYYMMDD_HHMMSS(String st) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + return sdf.parse(st); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static Date parseYYYYMMDD(String st) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + return sdf.parse(st); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static Date parseDotYYYYMMDD(String st) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); + try { + return sdf.parse(st); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static Date parseDotCommon(String st) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); + try { + return sdf.parse(st); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + public static long convertAllTimeToTemp(String st) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -103,12 +153,34 @@ return 0; } + public static String formatDate(long time) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm"); + String date = sdf.format(new Date(time)); + return date; + } + public static String formatDate(Date time) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm"); String date = sdf.format(time); return date; } + public static String formatDateDot(Date time) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); + String date = sdf.format(time); + return date; + } + + public static String formatDateAddT(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + try { + return sdf.format(date); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + public static long convertToTimeTemp(String st, String format) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(format); @@ -132,6 +204,7 @@ } return 0; } + public static long convertDateToTemp2(String st) { Date date = new Date(); @@ -210,6 +283,18 @@ return format; } + public static String getMonthOnlyMM(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("MM"); + String format = sdf.format(date); + return format; + } + + public static String getYearOnlyYYYY(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + String format = sdf.format(date); + return format; + } + public static int getDayOfMonth() { Calendar aCalendar = Calendar.getInstance(Locale.CHINA); int day = aCalendar.getActualMaximum(Calendar.DATE); -- Gitblit v1.8.0