[英]Java Formatting Date String
我需要轉換此20140815
進入15.08.2014
並進入15.08.2014 00:00:00
我該怎么做,Java中有哪些機會
您可以按如下方式使用SimpleDateFormat
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat outputFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
Date date = inputFormat.parse("20140815");
String result = outputFormat.format(date);
為什么要麻煩日期...只使用字符串:
String output = input.replaceAll("(....)(..)(..)", "$3.$2.$1");
要么
String output = input.replaceAll("(....)(..)(..)", "$3.$2.$1 00:00:00");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.