Java Day of parseCalendarDayFormat(String strDate)

Here you can find the source of parseCalendarDayFormat(String strDate)

Description

parse Calendar Day Format

License

Apache License

Parameter

Parameter Description
strDate a parameter

Return

java.util.Calendar

Declaration

public static synchronized Calendar parseCalendarDayFormat(String strDate) 

Method Source Code


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

import java.text.*;
import java.util.*;

public class Main {
    private static SimpleDateFormat sdf = new SimpleDateFormat();

    /**/*from   w ww . j  av a  2 s.com*/
     * @param strDate
     * @return java.util.Calendar
     */
    public static synchronized Calendar parseCalendarDayFormat(String strDate) {
        String pattern = "yyyy-MM-dd";
        return parseCalendarFormat(strDate, pattern);
    }

    /**
     * @param strDate
     * @return java.util.Calendar
     */
    public static synchronized Calendar parseCalendarFormat(String strDate) {
        String pattern = "yyyy-MM-dd HH:mm:ss";
        return parseCalendarFormat(strDate, pattern);
    }

    /**
     * @param strDate
     * @param pattern
     * @return java.util.Calendar
     */
    public static synchronized Calendar parseCalendarFormat(String strDate, String pattern) {
        synchronized (sdf) {
            Calendar cal = null;
            sdf.applyPattern(pattern);
            try {
                sdf.parse(strDate);
                cal = sdf.getCalendar();
            } catch (Exception e) {
            }
            return cal;
        }
    }

    public static synchronized Calendar getCalendar() {
        return GregorianCalendar.getInstance();
    }
}

Related

  1. minDayToLong(String time)
  2. minusDate(int day, int type)
  3. nextDay(Date date)
  4. nowDayString()
  5. parseBirthday(String r)
  6. parseDay(Date value, String defaultValue)
  7. parseDay(final String day)
  8. parseDay(int time)
  9. parseDay(String str, String type)