Here you can find the source of dateFormatFix(String str)
public static String dateFormatFix(String str)
//package com.java2s; /******************************************************************************* * Copyright (c) Emil Crumhorn - Hexapixel.com - emil.crumhorn@gmail.com * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*w ww .ja va 2 s . c o m*/ * emil.crumhorn@gmail.com - initial API and implementation *******************************************************************************/ public class Main { public static String dateFormatFix(String str) { if (str.indexOf("M") != -1 && str.indexOf("MM") == -1 && str.indexOf("MMM") == -1) { str = str.replaceAll("M", "MM"); } if (str.indexOf("d") != -1 && str.indexOf("dd") == -1 && str.indexOf("ddd") == -1) { str = str.replaceAll("d", "dd"); } if (str.indexOf("y") != -1 && str.indexOf("yy") == -1 && str.indexOf("yyy") == -1) { str = str.replaceAll("y", "yy"); } return str; } }