Java Calendar from Date date2Calendar(Date date)

Here you can find the source of date2Calendar(Date date)

Description

date Calendar

License

Open Source License

Declaration

public static Calendar date2Calendar(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static Calendar date2Calendar(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);/*w ww . j a  v a2  s. c om*/
        return cal;
    }

    private static Calendar setTime(final Calendar calendat, final String[] test) {
        if (test.length == 3) {
            calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim()));
            calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim()));
            calendat.set(Calendar.SECOND, Integer.parseInt(test[2].trim()));
        }
        if (test.length == 2) {
            calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim()));
            calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim()));
            calendat.set(Calendar.SECOND, 0);
        }
        return calendat;
    }
}

Related

  1. convertDateToCalendar(Date date)
  2. convertDateToCalendar(Date date)
  3. convertDateToCalendar(final Date d, boolean lenient)
  4. convertDateToCalendar(final Date dateToCompare)
  5. date2Calendar(Date date)
  6. date2Calendar(Date date)
  7. Date2Calendar(Date inDate)
  8. dateToCalendar(Date d)
  9. dateToCalendar(Date d)