| | |
| | | try { |
| | | TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); |
| | | //TimeZone tz = TimeZone.getTimeZone("GMT-01"); |
| | | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+'z"); |
| | | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+'08:00"); |
| | | df.setTimeZone(tz); |
| | | String nowAsISO = df.format(date); |
| | | return nowAsISO; |
| | |
| | | |
| | | if (date == null) |
| | | return ""; |
| | | try { |
| | | String nowDate = sdfLong.format(date); |
| | | return nowDate; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | public static String getShortTimeToNull(Date date) { |
| | | |
| | | if (date == null) |
| | | return null; |
| | | try { |
| | | String nowDate = sdfLong.format(date); |
| | | return nowDate; |
| | |
| | | } |
| | | int nday = caln.get(Calendar.DAY_OF_YEAR); |
| | | days = days + nday - oday; |
| | | |
| | | return days; |
| | | } |
| | | |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | try { |
| | | System.out.println(RandomStringUtils.randomNumeric(3)); |
| | | Date date = getISO8601DateByStr("2024-02-21T15:46:36.014+08:00"); |
| | | System.out.println(getISO8601Timestamp(date)); |
| | | |
| | | |
| | | Date date = getISO8601DateByStr("2024-04-15T07:46:36.014+08:00"); |
| | | Date date1 = getISO8601DateByStr("2024-06-14T08:46:36.014+08:00"); |
| | | System.out.println(daysBetweenDates11(date1,date)+1); |
| | | |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |