提交
This commit is contained in:
@@ -613,6 +613,10 @@ public class DateUtils {
|
||||
private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
|
||||
|
||||
private final static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static String getSdfTimes() {
|
||||
return sdfTimes.format(new Date());
|
||||
}
|
||||
@@ -625,6 +629,11 @@ public class DateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static String convertString(String str){
|
||||
StringBuilder stringBuilder=new StringBuilder();
|
||||
stringBuilder.append(str.substring(0,4));
|
||||
@@ -637,10 +646,38 @@ public class DateUtils {
|
||||
|
||||
|
||||
|
||||
public static Date convertDate1(String date) {
|
||||
try {
|
||||
return sdf1.parse(date);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Date convertDateByString(String str){
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.append(str.substring(0,4));
|
||||
sb.append("-");
|
||||
sb.append(str.substring(4,6));
|
||||
sb.append("-");
|
||||
sb.append(str.substring(6,8));
|
||||
sb.append(" ");
|
||||
sb.append(str.substring(8,10));
|
||||
sb.append(":");
|
||||
sb.append(str.substring(10,12));
|
||||
sb.append(":");
|
||||
sb.append(str.substring(12,14));
|
||||
|
||||
return convertDate1(sb.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
|
||||
|
||||
System.out.println(DateUtils.parse("20230707172528","yyyyMMddHHmmss"));
|
||||
System.out.println(DateUtils.convertDateByString("20240121141246"));
|
||||
//List<String> last6Months = getLast6Months();
|
||||
// List<String> last6Months = new ArrayList<>();
|
||||
// last6Months.add("2019-11");
|
||||
|
||||
Reference in New Issue
Block a user