[Original] A code about the date comparison and arrangement!

xiaoxiao2021-03-06  41

Import java.text.dateFormat; import java.text.SIMPLIC STRINGMMAT; arraylist postlist) {int n = postlist.size (); string [] arraydate = new string [n]; for (int i = 0; i i; J-CHECKDATETIME (ArrayDate [J]) {TEMP = arraydate [j]; arraydate [j] = arraydate [j -1]; arraydate [j-1] = Temp; FLAG = 1;} if (flag == 0) Break;} return arraydate [n-1]; // can return array according to yourself to return}

public boolean CheckDatetime (String StartDatetime, String EndDateTime) {// compare two date size try {String format_str = "yyyy-MM-dd hh: mm: ss"; Date dateStr = FormatTODay (StartDatetime, format_str); Date dateEnd = FormatToday (enddatetime, format_str); if (dateend) {return true;} else {return false;}} catch (exception ex) {ex.printstacktrace (system.err); returnaf false;}}}

public Date FormatTODay (String str, String Format_str) {// apply formatting try {SimpleDateFormat formatter = new SimpleDateFormat (Format_str); Date d = formatter.parse (str); return d; / * return formatter.format (d); * /} CatCH (Exception EX) {EX.PrintStackTrace (System.err); Return Null;}}

public String FormatTOString (String str, String Format_str) {// turn into character output channeling try {SimpleDateFormat formatter = new SimpleDateFormat (Format_str); Date d = formatter.parse (str); return formatter.format (d);} catch ( Exception ex) {EX.PrintStackTrace (System.err); Return Str;}}

转载请注明原文地址:https://www.9cbs.com/read-60582.html

New Post(0)