不多说,直接上干货!
timereplace.java
package zhouls.bigdata.DataFeatureSelection.util; /* * 这个程序,是用来做补充的 */ public class timereplace { public static void main(String[] args) { String rawtime = "2017-01-16 22:28:26.0"; String rawtime1 = rawtime.replaceAll("-", ":");//2017:01:16 22:28:26.0 String rawtime2 = rawtime1.replaceAll(" ", ":");//2017:01:16:22:28:26.0 System.out.println(rawtime2.substring(0, 19)); //打印字符串2017:01:16:22:28:26 } }