Java Date Convert convertStringToDate(String date)

Here you can find the source of convertStringToDate(String date)

Description

Converts date in the string format 'dd.mm.yyyy' to an date object.

License

Open Source License

Parameter

Parameter Description
date String in format 'dd.mm.yyyy' where months starts at '01'

Return

Date object of the given date

Declaration

public static Calendar convertStringToDate(String date) 

Method Source Code

//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);
    }
}

Related

  1. convertLocalToGMT(int[] dateTime)
  2. convertLocalToTimezone(Date original, String targetTimezoneId)
  3. convertsDateToGMTTimezone(Date date)
  4. convertSistemDependentDateToDesiredTimeZone(final Date sistemDependentDate, TimeZone desiredTimeZone)
  5. convertStringToDate(String date)
  6. convertStringToDate(String string)
  7. convertToClientTime(Date serverDate, Integer clientTimezoneOffset)
  8. convertToDate(String source)
  9. convertToDateStamp(long time)