Here you can find the source of parseStringDateToRmFormat(String date)
Parameter | Description |
---|---|
timestamp | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static String parseStringDateToRmFormat(String date)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*w w w . ja v a2 s . com*/ * Convert String from dd.MM.yyyy to yyyy-MM-dd. * * @param timestamp * @return * @throws Exception */ public static String parseStringDateToRmFormat(String date) { SimpleDateFormat sdfOld = new SimpleDateFormat("dd.MM.yyyy"); SimpleDateFormat sdfNew = new SimpleDateFormat("yyyy-MM-dd"); Date d; try { d = sdfOld.parse(date); } catch (ParseException e) { e.printStackTrace(); return null; } return sdfNew.format(d); } }