Java String to Time getCalendarForSpecifiedDate(final String dateTime)

Here you can find the source of getCalendarForSpecifiedDate(final String dateTime)

Description

Gets the calendar for specified date.

License

Open Source License

Parameter

Parameter Description
dateTime the date time

Exception

Parameter Description
ParseException the parse exception

Return

the calendar for specified date

Declaration

public static Calendar getCalendarForSpecifiedDate(final String dateTime) throws ParseException 

Method Source Code


//package com.java2s;
/*// www .ja va2 s  .c o m
 * DateUtil.java
 * Copyright (c) 2014, EcoFactor, All Rights Reserved.
 *
 * This software is the confidential and proprietary information of EcoFactor
 * ("Confidential Information"). You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you entered into with
 * EcoFactor.
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import java.util.Locale;

public class Main {
    public static final String DATE_FMT_FULL = "yyyy-MM-dd HH:mm:ss aa";

    /**
     * Gets the calendar for specified date.
     * @param dateTime the date time
     * @return the calendar for specified date
     * @throws ParseException the parse exception
     */
    public static Calendar getCalendarForSpecifiedDate(final String dateTime) throws ParseException {

        final Calendar calTime = Calendar.getInstance();
        final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FMT_FULL, Locale.ENGLISH);
        final Date date = (Date) sdf.parse(dateTime);
        calTime.setTime(date);
        return calTime;
    }
}

Related

  1. getAsDateTime(String dateTime)
  2. getCalendarFromCPEGeneratorDateTime(String cpeDateTime)
  3. getCalendarFromDate(final String dateTime)
  4. getDlayDateTime(String playDate, String playTime)
  5. getEndTime(String flag, int value)