//WP "2017-11-27T15:29:37" public static String getFormattedWPDate(String modified) { try { String wp_format = "yyyy-MM-dd'T'HH:mm:ss"; String new_format = "MM/dd/yyyy HH:MM:SS a"; final SimpleDateFormat newFormat = new SimpleDateFormat( wp_format, Locale.getDefault() ); Date date = newFormat.parse(modified); // new Date(modified);// newFormat.setTimeZone(UTC);// System.out.println("newFormat.format(Dates.BEGINNING_OF_TIME) = " + newFormat.format(BEGINNING_OF_TIME));// System.out.println("newFormat.format(Dates.END_OF_TIME) = " + newFormat.format(END_OF_TIME));// //System.out.println("newFormat.format(new Date()) = " + newFormat.format(new Date()));//// System.out.println("newFormat.parse(\"2015-04-28T14:23:38.521Z\") = " + newFormat.parse("2015-04-28T14:23:38.521Z"));// System.out.println("newFormat.parse(\"0001-01-01T00:00:00.000Z\") = " + newFormat.parse("0001-01-01T00:00:00.000Z"));// System.out.println("newFormat.parse(\"292278994-08-17T07:12:55.807Z\") = " + newFormat.parse("292278994-08-17T07:12:55.807Z")); SimpleDateFormat DesiredFormat = new SimpleDateFormat(new_format, Locale.getDefault()); // 'a' for AM/PM return DesiredFormat.format(date.getTime()); //return newFormat.format(date); } catch (Exception e) { e.printStackTrace(); return ""; } }
Комментариев нет:
Отправить комментарий