Here you can find the source of formatDate(String dateString, String delimiter)
public static String formatDate(String dateString, String delimiter)
//package com.java2s; /**// w w w . j a v a 2s. co m * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved. * This software is the confidential and proprietary information of SK holdings. * You shall not disclose such confidential information and shall use it only in * accordance with the terms of the license agreement you entered into with SK holdings. * (http://www.eclipse.org/legal/epl-v10.html) */ public class Main { public static String formatDate(String dateString, String delimiter) { if (dateString == null) return ""; //$NON-NLS-1$ String output = dateString.replaceAll("[^0-9]", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (output.length() == 8) { return (output.substring(0, 4) + delimiter + output.substring(4, 6) + delimiter + output.substring(6, 8)); } else if (output.length() == 6) { return (output.substring(0, 4) + delimiter + output.substring(4, 6)); } else { return ""; //$NON-NLS-1$ } } }