List of usage examples for java.util Date getMonth
@Deprecated public int getMonth()
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??// w ww .jav a 2 s . c om * @param date * @return */ public static String getLastTime(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); Date lastDate = cal.getTime(); lastDate.setHours(23); lastDate.setMinutes(59); lastDate.setSeconds(59); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(lastDate); }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?//w w w . j a v a 2 s .c om * @param date * @return */ public static Date getFirstTimeDate(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, 1); Date firstDate = cal.getTime(); firstDate.setHours(0); firstDate.setMinutes(0); firstDate.setSeconds(0); return firstDate; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?/*from w w w . j ava2 s . c om*/ * @param date * @return */ public static String getFirstTime(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, 1); Date firstDate = cal.getTime(); firstDate.setHours(0); firstDate.setMinutes(0); firstDate.setSeconds(0); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(firstDate); }
From source file:com.cssweb.quote.util.Utils.java
public static String format(Date date) { String str = ""; str = date.getYear() + "-" + formatTwo(date.getMonth() + 1) + "-" + formatTwo(date.getDate()) + " " + formatTwo(date.getHours()) + ":" + formatTwo(date.getMinutes()) + ":00"; return str;//from w w w. j a v a2 s .c om }
From source file:com.camel.framework.utils.DateUtils.java
/** * ?/*from ww w . j a v a 2 s. c o m*/ * * @param strEndDate * @return */ @SuppressWarnings("deprecation") public static String getMonthDayDateString(String strEndDate) { Date objDate = getStringDate(strEndDate, STANDARD); return String.valueOf(objDate.getMonth()); }
From source file:org.infoscoop.request.filter.rss.RssHandler.java
/** * Return the date whose form is "yyyy/MM/dd HH:mm:ss" -> obsolute * javascript Date :An argument form of the object instance. * Return the date whose form is "yyyy,MM,dd,HH,mm,ss". * /*from www. jav a 2 s . c om*/ * @param date * @return */ public static String getFullDate(Date date) { if (date == null) { return null; } try { // return formatFullDate.format(date); return (date.getYear() + 1900) + "," + date.getMonth() + "," + date.getDate() + "," + date.getHours() + "," + date.getMinutes() + "," + date.getSeconds(); } catch (IllegalArgumentException e1) { return null; } }
From source file:it.scoppelletti.mobilepower.types.SimpleDate.java
/** * Restituisce la data rappresentata da una stringa in formato ISO 8601 * ({@code yyyy-MM-dd})./* w w w.j a v a 2s. c o m*/ * * @param s Stringa. * @return Data. Se la stringa {@code s} è nulla, restituisce la * data nulla. * @see #NIL * @see #isEmpty */ public static SimpleDate fromISOString(String s) throws ParseException { Date value; SimpleDate date; SimpleDateFormat fmt; if (StringUtils.isBlank(s)) { return SimpleDate.NIL; } fmt = new SimpleDateFormat("yyyy-MM-dd"); value = fmt.parse(s); date = new SimpleDate(1900 + value.getYear(), value.getMonth(), value.getDate()); return date; }
From source file:eionet.meta.exports.ods.Ods.java
/** * Returns date.//from w w w . j a v a 2 s .co m * * @param timestamp * time stamp * * @return date as a string */ public static String getDate(long timestamp) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth() + 1); month = (month.length() < 2) ? ("0" + month) : month; String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; String hours = String.valueOf(date.getHours()); hours = (hours.length() < 2) ? ("0" + hours) : hours; String minutes = String.valueOf(date.getMinutes()); minutes = (minutes.length() < 2) ? ("0" + minutes) : minutes; String seconds = String.valueOf(date.getSeconds()); seconds = (seconds.length() < 2) ? ("0" + seconds) : seconds; String time = year; time = time + "-" + month; time = time + "-" + day; time = time + "T" + hours; time = time + ":" + minutes; time = time + ":" + seconds; return time; }
From source file:com.krawler.esp.handlers.basecampHandler.java
public static long getDiff(Date dt1, Date dt2) { Date dt3 = new Date(dt1.getYear(), dt1.getMonth(), dt1.getDate()); Date dt4 = new Date(dt2.getYear(), dt2.getMonth(), dt2.getDate()); long diff = (dt3.getTime() - dt4.getTime()) / (1000 * 60 * 60 * 24); return diff;/*from ww w .j a v a2s . c om*/ }
From source file:org.rifidi.emulator.reader.llrp.report.LLRPReportController.java
/** * Gets the UTC Time.//from w ww. ja v a 2 s. c om * * @param dateString * @param timeString * @return time in milliseconds */ @SuppressWarnings("deprecation") private static long getUTCTimeInMillis(String dateString, String timeString) { /* * TODO: baindaid solution until radio saves and returns java date and * time objects */ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); Date date, time = null; try { date = dateFormat.parse(dateString); time = timeFormat.parse(timeString); } catch (ParseException e) { logger.error("There was a problem converting the date or time string into a Date object"); date = new Date(); time = new Date(); } GregorianCalendar gc = new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes(), time.getSeconds()); return gc.getTimeInMillis(); }