List of usage examples for java.util Date getHours
@Deprecated public int getHours()
From source file:Main.java
public static String date2str(Date date) { if (date == null) return null; return date2str(date.getYear() + 1900, date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes());/* ww w.ja v a 2s.c o m*/ }
From source file:Main.java
public static Date getTaskDueDateFromIso8601String(String s) { System.err.println("Importing date string: " + s); Date date = getDateFromIso8601String(s); System.err.println("Got date: " + date); if (date != null) { if (date.getHours() == 23 && date.getMinutes() == 59 && date.getSeconds() == 59) { date.setHours(12);//ww w.j a v a 2 s . com date.setMinutes(0); date.setSeconds(0); } } return date; }
From source file:Main.java
public static int milli2int(long milli) { Date date = new Date(milli); int total = 0; int year = date.getYear() - 112; int month = date.getMonth() + 1; int day = date.getDate(); int hour = date.getHours(); int minute = date.getMinutes(); int sec = date.getSeconds(); total = year << 26;//from www .ja v a2 s. c om total |= month << 22; total |= day << 17; total |= hour << 12; total |= minute << 6; total |= sec; return total; }
From source file:Main.java
public static String getCurrentTimeString() { Date timeDate = new Date(System.currentTimeMillis()); String min = "" + timeDate.getMinutes(); if (min.length() < 2) { min = "0" + min; }//w w w .j a va 2s . c om String h = "" + timeDate.getHours(); if (h.length() < 2) { h = "0" + h; } return h + ":" + min; }
From source file:com.b5m.user.frame.util.DateUtils.java
/** * ? //from w w w . j ava2s . com * @return int */ public static int remainSecondsInToday() { int remainSeconds = DAY_SECONDS; Date date = new Date(); int currentTimeSendcods = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds(); remainSeconds = DAY_SECONDS - currentTimeSendcods; return remainSeconds; }
From source file:Main.java
/** * Gets the default ARO trace folder name in the HH:MM:SS:DD:MM:YY format. * //from ww w.jav a 2 s . c om * @return The default ARO trace folder name. */ public static String getDefaultTraceFolderName() { final Date systemDate = new Date(); final Calendar now = Calendar.getInstance(); final int currenthours = systemDate.getHours(); final int currentminutes = systemDate.getMinutes(); final int currentseconds = systemDate.getSeconds(); final int currentdate = now.get(Calendar.DATE); // java calendar int currentmonth = now.get(Calendar.MONTH); // As Jan is defined as 0 in currentmonth = currentmonth + 1; if (currentmonth >= 13) // As Jan is defined as 0 in java calendar currentmonth = 1; String currentMonth = Integer.toString(currentmonth); String currentDate = Integer.toString(currentdate); String currentHours = Integer.toString(currenthours); String currentMinutes = Integer.toString(currentminutes); String currentSeconds = Integer.toString(currentseconds - 1); if (currentmonth < 10) { currentMonth = ""; currentMonth = "0" + currentmonth; } if (currentdate < 10) { currentDate = ""; currentDate = "0" + currentdate; } if (currenthours < 10) { currentHours = ""; currentHours = "0" + currenthours; } if (currentminutes < 10) { currentMinutes = ""; currentMinutes = "0" + currentminutes; } if (currentseconds < 10) { currentSeconds = ""; currentSeconds = "0" + currentseconds; } final String folderName = now.get(Calendar.YEAR) + "-" + currentMonth + "-" + currentDate + "-" + currentHours + "-" + currentMinutes + "-" + currentSeconds; return folderName; }
From source file:ch.ethz.inf.vs.android.g54.a4.util.SnapshotCache.java
private static String constructFileName(String name) { Date d = new Date(); return String.format("%d-%d-%d_%d-%d-%d_%s.%s", d.getYear() + 1900, d.getMonth(), d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds(), name, FILE_EXTENSION); }
From source file:net.duckling.ddl.web.api.APITeamUpdatesController.java
@SuppressWarnings("deprecation") private static AoneNoticeParam getMobileTeamNoticeQueryParam(int tid, String date, int offset) { AoneNoticeParam p = new AoneNoticeParam(tid, NoticeRule.TEAM_NOTICE, tid + ""); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date begin = null;//from ww w . j av a2s .com try { if (date != null) { begin = dateFormat.parse(date); if (offset > 0) { // ?? Date now = new Date(); int hour = now.getHours(); int minute = now.getMinutes(); long time = begin.getTime() + hour * 60 * 60 * 1000 + minute * 60 * 1000; begin = new Date(time); } } else { begin = new Date(); } } catch (ParseException e) { begin = new Date(); } p.setBeginDate(DateUtils.addDays(begin, DEFAULT_MOBILE_DURATION)); p.setEndDate(begin); return p; }
From source file:com.fluidops.iwb.api.valueresolver.ValueResolverUtil.java
/** * Converts a system date like '2011-03-31T19:54:33' to user-readable date. * If the input is not a valid system date, the value is returned as is. * /*from w w w .j a v a2 s . co m*/ * @param sysdate * @return */ @SuppressWarnings("deprecation") public static String resolveSystemDate(String sysdate) { Date d = ReadDataManagerImpl.ISOliteralToDate(sysdate); if (d == null) return StringEscapeUtils.escapeHtml(sysdate); DateFormat df = null; if (d.getHours() == 0 && d.getMinutes() == 0 && d.getSeconds() == 0) df = new SimpleDateFormat("MMMMM dd, yyyy"); else df = new SimpleDateFormat("MMMMM dd, yyyy, HH:mm:ss"); return df.format(d); }
From source file:gov.nih.nci.cabig.caaers.utils.DateUtils.java
public static String formatDate(Date d) { if (d.getHours() > 0 || d.getMinutes() > 0) return formatDate(d, DATE_WITH_DATETIME); return formatDate(d, DATE_PATTERN); }