Here you can find the source of convertStringToDate(String date)
Parameter | Description |
---|---|
date | String in format 'dd.mm.yyyy' where months starts at '01' |
public static Calendar convertStringToDate(String date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /**//ww w. ja v a2 s. c om * Converts date in the string format 'dd.mm.yyyy' to an date object. * * @param date * String in format 'dd.mm.yyyy' where months starts at '01' * @return Date object of the given date */ public static Calendar convertStringToDate(String date) { int day = Integer.parseInt(date.substring(0, 2)); // Month is 0-based int month = Integer.parseInt(date.substring(3, 5)) - 1; int year = Integer.parseInt(date.substring(6)); return new GregorianCalendar(year, month, day); } }