List of usage examples for java.util Date setHours
@Deprecated public void setHours(int hours)
From source file:Main.java
public static String formatTime(Context context, int timeValue) { Date date = new Date(); date.setHours(timeValue / 60); date.setMinutes(timeValue % 60);/* ww w . j ava 2s . c om*/ return formatTime(context, date); }
From source file:Util.java
/** * Sets the time on the same day to 00:00:00.000 * * @param date// www.j a v a 2s . c om * @return a new date */ @SuppressWarnings("deprecation") public static Date truncateTime(Date date) { Date newDate = (Date) date.clone(); newDate.setHours(0); newDate.setMinutes(0); newDate.setSeconds(0); newDate.setTime(newDate.getTime() - newDate.getTime() % 1000); //Millisekunden auf 0 return newDate; }
From source file:common.util.DateUtil.java
public static Date resetTime(Date date) { if (date != null) { date.setHours(0); date.setMinutes(0);//w ww. j av a2 s . c o m date.setSeconds(0); } return date; }
From source file:common.util.DateUtil.java
public static Date resetTimeCeiling(Date date) { if (date != null) { date.setHours(23); date.setMinutes(59);/* w w w .j a v a2 s . c o m*/ date.setSeconds(59); } return date; }
From source file:Main.java
public static Date getSpritDate(String str) { SimpleDateFormat format = new SimpleDateFormat("yyyy/M/d"); Date date = null; try {/* ww w. j a va 2 s . c o m*/ date = format.parse(str); date.setMinutes(0); date.setHours(0); date.setSeconds(0); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.dc.gameserver.extComponents.Kit.DateUtil.java
/** * 0//from w w w .java 2s. c o m * @param d1 ? * @param d2 ? * @return */ @SuppressWarnings("deprecation") public static int getDay1(Date d1, Date d2) { if (d1 == null) return 1; d1.setHours(0); d1.setMinutes(0); d1.setSeconds(0); d2.setHours(0); d2.setMinutes(0); d2.setSeconds(0); long date1 = d1.getTime() / (1000l * 60 * 60 * 24); long date2 = d2.getTime() / (1000l * 60 * 60 * 24); return Long.valueOf(date2 - date1).intValue(); }
From source file:Main.java
public static String calculateAge(Context context, String date) { final String FACEBOOK = "MM/dd/yyyy"; try {//from w ww . j a va 2 s. co m SimpleDateFormat sf = new SimpleDateFormat(FACEBOOK, Locale.ENGLISH); sf.setLenient(true); Date birthDate = sf.parse(date); Date now = new Date(); int age = now.getYear() - birthDate.getYear(); birthDate.setHours(0); birthDate.setMinutes(0); birthDate.setSeconds(0); birthDate.setYear(now.getYear()); if (birthDate.after(now)) { age -= 1; } return Integer.toString(age); } catch (Exception e) { Log.d("DEBUG", "exception in getTwitterDate:"); e.printStackTrace(); return "Unknown"; } }
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); date.setMinutes(0);/*from w ww.j a va2s .co m*/ date.setSeconds(0); } } return date; }
From source file:com.synox.android.utils.DisplayUtils.java
@SuppressWarnings("deprecation") public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags) { CharSequence dateString = ""; // in Future//from w w w. jav a 2 s . c om if (time > System.currentTimeMillis()) { return DisplayUtils.unixTimeToHumanReadable(time); } // < 60 seconds -> seconds ago else if ((System.currentTimeMillis() - time) < 60 * 1000) { return c.getString(R.string.file_list_seconds_ago); } else { // Workaround 2.x bug (see https://github.com/owncloud/android/issues/716) if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB && (System.currentTimeMillis() - time) > 24 * 60 * 60 * 1000) { Date date = new Date(time); date.setHours(0); date.setMinutes(0); date.setSeconds(0); dateString = DateUtils.getRelativeDateTimeString(c, date.getTime(), minResolution, transitionResolution, flags); } else { dateString = DateUtils.getRelativeDateTimeString(c, time, minResolution, transitionResolution, flags); } } return dateString.toString().split(",")[0]; }
From source file:gov.nih.nci.cabig.caaers.utils.DateUtils.java
/** * This is a convenient method to get yesterday date * @return/*from www . j a v a2 s. c o m*/ */ public static Date yesterday() { Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, -1); Date d = c.getTime(); d.setHours(0); d.setMinutes(0); return d; }