Java Date to Calendar toCalendar(final Date date, final Locale locale)

Here you can find the source of toCalendar(final Date date, final Locale locale)

Description

to Calendar

License

LGPL

Declaration

public static Calendar toCalendar(final Date date, final Locale locale) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.*;

public class Main {
    public static Calendar toCalendar(final Date date, final Locale locale) {
        if (date == null) {
            return null;
        }//from   ww w  .  j av  a2s.  c  o m

        Calendar cal;
        if (locale == null) {
            cal = Calendar.getInstance();
        } else {
            cal = Calendar.getInstance(locale);
        }
        cal.setTime(date);
        // HACK: Force all fields to update. see link for explanation of this.
        //http://java.sun.com/j2se/1.4/docs/api/java/util/Calendar.html
        cal.getTime();
        return cal;
    }
}

Related

  1. toCalendar(Date date)
  2. toCalendar(Date date)
  3. toCalendar(Date dtime)
  4. toCalendar(Date value)
  5. toCalendar(final Date date)
  6. toCalendar(final Date date, final TimeZone tz)