List of usage examples for java.util Date getYear
@Deprecated public int getYear()
From source file:Main.java
static public void appendDateNode(Document owner, Element appendElement, String name, Date date) { Element dateElem = owner.createElement(name); appendElement.appendChild(dateElem); appendSingleValElement(owner, dateElem, "month", Integer.toString(date.getMonth() + 1)); appendSingleValElement(owner, dateElem, "day", Integer.toString(date.getDate())); appendSingleValElement(owner, dateElem, "year", Integer.toString(date.getYear() + 1900)); appendSingleValElement(owner, dateElem, "hour", Integer.toString(date.getHours())); appendSingleValElement(owner, dateElem, "minute", Integer.toString(date.getMinutes())); appendSingleValElement(owner, dateElem, "second", Integer.toString(date.getSeconds())); }
From source file:com.qingzhi.apps.fax.util.UIUtils.java
public static String getDataFormat(String time) { String formatTime = ""; try {/*from www . ja va2 s . c om*/ Date date = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS").parse(time); Date nowDate = new Date(); if (date.getYear() == nowDate.getYear() && date.getMonth() == nowDate.getMonth() && date.getDate() == nowDate.getDate()) { formatTime = "" + new SimpleDateFormat("HH:mm:ss").format(date); } else if (date.getYear() == nowDate.getYear() && date.getMonth() == nowDate.getMonth() && date.getDate() == (nowDate.getDate() - 1)) { formatTime = "" + new SimpleDateFormat("HH:mm:ss").format(date); } else if (date.getYear() == nowDate.getYear()) { formatTime = new SimpleDateFormat("MM-dd HH:mm").format(date); } else { formatTime = new SimpleDateFormat("yyyy-MM-dd").format(date); } } catch (Exception e) { formatTime = time; } return formatTime; }
From source file:foam.zizim.android.Util.java
public static void findDeletedIncidents(Context context) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new java.util.Date(); date.setYear(date.getYear() - 1); StringBuilder datetime = new StringBuilder(dateFormat.format(date)); String sinceDate = datetime.toString(); //request all deleted incidents from the last year try {// w w w . j a va2s.co m if (Incidents.getDeletedIncidentsFromWeb(sinceDate)) { List<IncidentsData> deletedIncidents = HandleXml .processIncidentsXml(BoskoiService.incidentsResponse, context); BoskoiApplication.mDb.deleteIncidents(deletedIncidents); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?//from w ww . j a v a 2s . c o m * @param date * @return */ public static int getLastTimeNum(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(); int sum = lastDate.getDate(); return sum; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??//www . j a va 2 s. c o m * @param date * @return */ public static Date getLastTimeDate(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); return lastDate; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??// ww w.j a va 2 s .c o m * @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
/** * ?//from ww w . ja va 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 ww. j a v a2s.c o m * @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;/*w ww. j a v a 2s . co m*/ }
From source file:nz.co.fortytwo.signalk.util.Util.java
/** * Attempt to set the system time using the GPS time * /*w w w . j a v a2s . com*/ * @param sen */ @SuppressWarnings("deprecation") public static void checkTime(RMCSentence sen) { if (timeSet) return; try { net.sf.marineapi.nmea.util.Date dayNow = sen.getDate(); // if we need to set the time, we will be WAAYYY out // we only try once, so we dont get lots of native processes // spawning if we fail timeSet = true; Date date = new Date(); if ((date.getYear() + 1900) == dayNow.getYear()) { if (logger.isDebugEnabled()) logger.debug("Current date is " + date); return; } // so we need to set the date and time net.sf.marineapi.nmea.util.Time timeNow = sen.getTime(); String yy = String.valueOf(dayNow.getYear()); String MM = pad(2, String.valueOf(dayNow.getMonth())); String dd = pad(2, String.valueOf(dayNow.getDay())); String hh = pad(2, String.valueOf(timeNow.getHour())); String mm = pad(2, String.valueOf(timeNow.getMinutes())); String ss = pad(2, String.valueOf(timeNow.getSeconds())); if (logger.isDebugEnabled()) logger.debug("Setting current date to " + dayNow + " " + timeNow); String cmd = "sudo date --utc " + MM + dd + hh + mm + yy + "." + ss; Runtime.getRuntime().exec(cmd.split(" "));// MMddhhmm[[yy]yy] if (logger.isDebugEnabled()) logger.debug("Executed date setting command:" + cmd); } catch (Exception e) { logger.error(e.getMessage(), e); } }