Example usage for java.util Date setSeconds

List of usage examples for java.util Date setSeconds

Introduction

In this page you can find the example usage for java.util Date setSeconds.

Prototype

@Deprecated
public void setSeconds(int seconds) 

Source Link

Document

Sets the seconds of this Date to the specified value.

Usage

From source file:Util.java

/**
 * Sets the time on the same day to 00:00:00.000
 *
 * @param date/*from   w  w w. ja va2  s. co m*/
 * @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:Main.java

public static Date getSpritDate(String str) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy/M/d");
    Date date = null;

    try {/*from   w ww.j  a v  a  2  s. c om*/
        date = format.parse(str);
        date.setMinutes(0);
        date.setHours(0);
        date.setSeconds(0);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return date;
}

From source file:common.util.DateUtil.java

public static Date resetTime(Date date) {
    if (date != null) {
        date.setHours(0);//w  w  w.  j  a v a2s . c o m
        date.setMinutes(0);
        date.setSeconds(0);
    }
    return date;
}

From source file:common.util.DateUtil.java

public static Date resetTimeCeiling(Date date) {
    if (date != null) {
        date.setHours(23);/*from w w  w  . j  av a2s. c  o m*/
        date.setMinutes(59);
        date.setSeconds(59);
    }
    return date;
}

From source file:com.dc.gameserver.extComponents.Kit.DateUtil.java

/**
 * 0/*from   w ww .j  a  v a2s .c  om*/
 * @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   www .  j av a2  s . c o  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);/*from w  w w  .j a va 2 s  .  c om*/
            date.setMinutes(0);
            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// w ww .  ja  va2s  .  c o  m
    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:com.sccl.attech.common.utils.DateUtils.java

/**
 * ??? 00//from   w w w . jav a2 s .  c o  m
 * @param time
 * @return
 */
public static Date getDateByMinLow(Long time) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(time);
    Date date = c.getTime();
    date.setSeconds(0);
    return date;
}

From source file:com.sccl.attech.common.utils.DateUtils.java

/**
 * ??? 59/* w ww.  j  a v a  2 s.c om*/
 * @param time
 * @return
 */
public static Date getDateByMinUp(Long time) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(time);
    Date date = c.getTime();
    date.setSeconds(59);
    return date;
}