Here you can find the source of getMM(String strDate)
Parameter | Description |
---|---|
strDate | java.lang.String |
public static int getMM(String strDate)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /** Constante que define el patron estandar de presentacion de fechas */ private static final String PATRON_FECHA_DEFAULT = "dd/MM/yyyy"; /**//from w w w . j a va2 s .c o m * Insert the method's description here. Creation date: (25/05/2002 08:19:24 p.m.) * * @param strDate java.lang.String * @param pattern DOCUMENT ME! * * @return int */ public static int getMM(String strDate, String pattern) { Calendar calendar = Calendar.getInstance(); calendar.setTime(convertStringToDate(strDate, pattern)); return calendar.get(Calendar.MONTH) + 1; } /** * Insert the method's description here. Creation date: (25/05/2002 08:19:24 p.m.) * * @param strDate java.lang.String * * @return int */ public static int getMM(String strDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(convertStringToDate(strDate)); return calendar.get(Calendar.MONTH) + 1; } /** * Convertidor de cadenas con el patron 'dd/MM/yyyy' a fechas * * @param stringDate La cadena a transformar * * @return La fecha transformada */ public static java.util.Date convertStringToDate(String stringDate) { return convertStringToDate(stringDate, PATRON_FECHA_DEFAULT); } public static java.util.Date convertStringToDate(String stringDate, String pattern) { java.util.Date date = null; try { SimpleDateFormat formatter = new SimpleDateFormat(pattern); formatter.setLenient(true); date = formatter.parse(stringDate); } catch (Exception e) { date = new java.util.Date(); } return date; } }