Java Calendar from Date convertDateToCalendar(final Date d, boolean lenient)

Here you can find the source of convertDateToCalendar(final Date d, boolean lenient)

Description

Convert a Date object into a Calendar object.

License

Apache License

Parameter

Parameter Description
d The date to convert
lenient Should parsing be lenient

Return

a Calendar object

Declaration

public static final Calendar convertDateToCalendar(final Date d, boolean lenient) 

Method Source Code

//package com.java2s;
/**//from w  w w.  ja  v a  2  s.  c  o  m
 * This is a helper class for the FindPerson() service.
 * It contains several methods used by the FindPerson service.
 * 
 * After instantiating this class, the user should call
 * getMatchCodes() to populate the match codes using the GI
 * service. Then the matchNameMatchCodeFromCPR(),
 * matchAddressMatchCodeFromCPR(), and matchCityMatchCodeFromCPR()
 * methods may be used.
 * 
 * Copyright 2012 The Pennsylvania State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package edu.psu.iam.cpr.core.api.helper
 * @author $Author$
 * @version $Rev$
 * @lastrevision $Date$
 * 
 */

import java.util.Calendar;
import java.util.Date;

import java.util.Locale;

public class Main {
    /**
     * Convert a Date object into a Calendar object.
     * 
     * @param d The date to convert
     * @param lenient Should parsing be lenient
     * 
     * @return a Calendar object
     */
    public static final Calendar convertDateToCalendar(final Date d, boolean lenient) {

        Calendar cal = Calendar.getInstance(Locale.US);
        cal.setLenient(lenient);
        cal.setTime(d);

        return cal;
    }
}

Related

  1. calendarFromDate(Date date)
  2. convertDateToCalendar(Date date)
  3. convertDateToCalendar(Date date)
  4. convertDateToCalendar(Date date)
  5. convertDateToCalendar(final Date dateToCompare)
  6. date2Calendar(Date date)
  7. date2Calendar(Date date)
  8. date2Calendar(Date date)