Here you can find the source of getCalendarForSpecifiedDate(final String dateTime)
Parameter | Description |
---|---|
dateTime | the date time |
Parameter | Description |
---|---|
ParseException | the parse exception |
public static Calendar getCalendarForSpecifiedDate(final String dateTime) throws ParseException
//package com.java2s; /*// www .ja va2 s .c o m * DateUtil.java * Copyright (c) 2014, EcoFactor, All Rights Reserved. * * This software is the confidential and proprietary information of EcoFactor * ("Confidential Information"). You shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement you entered into with * EcoFactor. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static final String DATE_FMT_FULL = "yyyy-MM-dd HH:mm:ss aa"; /** * Gets the calendar for specified date. * @param dateTime the date time * @return the calendar for specified date * @throws ParseException the parse exception */ public static Calendar getCalendarForSpecifiedDate(final String dateTime) throws ParseException { final Calendar calTime = Calendar.getInstance(); final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FMT_FULL, Locale.ENGLISH); final Date date = (Date) sdf.parse(dateTime); calTime.setTime(date); return calTime; } }