Java examples for java.util:Date Format
convert Date Format from DdMMyy To YyyyMMyy
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static void main(String[] argv) throws Exception{ String str = "java2s.com"; System.out.println(convertDdMMyyToYyyyMMyy(str)); }/* w ww . j a va 2 s .c o m*/ public static String convertDdMMyyToYyyyMMyy(String str) { if (str == null || "".equals(str)) return str; if (str.length() < 6) { str = AppUtils.padLeft(str, 6, '0'); } SimpleDateFormat sdfEbank = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sdfCoreBank = new SimpleDateFormat("ddMMyy"); Date date = null; try { date = (Date) sdfCoreBank.parse(str); } catch (Exception ex) { ex.printStackTrace(); return ""; } return sdfEbank.format(date); } }