Java Calendar Create getCalendar(String str)

Here you can find the source of getCalendar(String str)

Description

get Calendar

License

Open Source License

Declaration


public static Calendar getCalendar(String str) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static Calendar getCalendar(String str) {
        int yy = Integer.parseInt(str.substring(0, 4));
        int mm = Integer.parseInt(str.substring(4, 6)) - 1;
        int dd = Integer.parseInt(str.substring(6, 8));

        Calendar cal = Calendar.getInstance();
        cal.set(yy, mm, dd);/* w  w w .ja v a  2  s .  c om*/
        return cal;
    }

    public static Calendar getCalendar(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal;
    }
}

Related

  1. getCalendar(long timeInMillis)
  2. getCalendar(String date)
  3. getCalendar(String dateStr, int inputYearType, int outputYearType)
  4. getCalendar(String dateString)
  5. getCalendar(String gdate)
  6. getCalendar(String time, char sep, boolean isStart)
  7. getCalendar(String yyyy, String mm, String dd)
  8. getCalendar(TimeZone timeZone, Locale locale)
  9. getCalendarAtMidnight(Date d)