Here you can find the source of formatDateString(String dateString)
Parameter | Description |
---|---|
dateString | a parameter |
public static String formatDateString(String dateString)
//package com.java2s; //License from project: Apache License public class Main { public static final String DEFAULT_DELIMETER = "-"; /**// w w w.j a v a 2 s.c om * Change date format from MM/dd/YYYY to yyyy/MM/dd * @param dateString * @return */ public static String formatDateString(String dateString) { // bulan-tanggal-tahun String arrStr[] = dateString.split(DEFAULT_DELIMETER); if (arrStr[1].length() == 1) arrStr[1] = String.format("0%s", arrStr[1]); if (arrStr[0].length() == 1) arrStr[0] = String.format("0%s", arrStr[0]); // tahun-bulan-tanggal return String.format("%s-%s-%s", arrStr[2], arrStr[0], arrStr[1]); } }