Example usage for java.util Calendar SECOND

List of usage examples for java.util Calendar SECOND

Introduction

In this page you can find the example usage for java.util Calendar SECOND.

Prototype

int SECOND

To view the source code for java.util Calendar SECOND.

Click Source Link

Document

Field number for get and set indicating the second within the minute.

Usage

From source file:J2MEFixedRateSchedule.java

public void startApp() {
    d.addCommand(new Command("Exit", Command.EXIT, 0));
    d.setCommandListener(new CommandListener() {
        public void commandAction(Command c, Displayable s) {
            notifyDestroyed();//from w  ww.ja  v  a  2  s. c  o  m
        }
    });
    now.setTime(currentTime);

    nowString = now.get(Calendar.HOUR) + ":" + now.get(Calendar.MINUTE) + ":" + now.get(Calendar.SECOND) + ":";

    aTimer = new Timer();
    aTimerTask = new ClockTimerTask();
    aTimer.scheduleAtFixedRate(aTimerTask, 10, 1000);

    Display.getDisplay(this).setCurrent(d);
}

From source file:com.qpark.eip.core.spring.auth.LimitedAccessDataProvider.java

/**
 * Get a {@link Date}, where hours, minutes, seconds and milliseconds are
 * set to 0.//from w  ww.j  a v  a  2s .c o m
 *
 * @return the {@link Date} and the corresponding log string.
 */
private static SimpleEntry<Date, String> getRequestDate() {
    Calendar gc = new GregorianCalendar();
    gc.set(Calendar.HOUR_OF_DAY, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    String hmss = String.format("%04d%02d%02d", gc.get(Calendar.YEAR), gc.get(Calendar.MONTH) + 1,
            gc.get(Calendar.DAY_OF_MONTH));
    SimpleEntry<Date, String> entry = new SimpleEntry<Date, String>(gc.getTime(), hmss);
    return entry;
}

From source file:Main.java

public static Date getDateTimeFrom(Date time, Date date) {
    Date iTime, iDate;/*from  www  . j  a  v a  2  s  .co m*/
    Calendar calendar = Calendar.getInstance();

    if (date == null) {
        iTime = time;
        iDate = new Date();
    } else {
        iTime = time;
        iDate = date;
    }

    Calendar calendarDate = Calendar.getInstance();
    calendarDate.setTime(iDate);

    Calendar calendarTime = Calendar.getInstance();
    if (iTime != null)
        calendarTime.setTime(iTime);

    if (iTime != null) {
        calendar.set(Calendar.MINUTE, calendarTime.get(Calendar.MINUTE));
        calendar.set(Calendar.HOUR_OF_DAY, calendarTime.get(Calendar.HOUR_OF_DAY));
    } else {
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
    }

    //calendar.set(Calendar.AM_PM, calendarTime.get(Calendar.AM_PM) );

    calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH));
    calendar.set(Calendar.MONTH, calendarDate.get(Calendar.MONTH));
    calendar.set(Calendar.YEAR, calendarDate.get(Calendar.YEAR));

    Date ret = calendar.getTime();
    Log.v("!!!!!!!!!! calendar=", "" + ret);

    return ret;
}

From source file:com.westlinkin.android_feedback_helper.utils.MailUntils.java

private static String getFeedbackNumber() {
    Calendar calendar = Calendar.getInstance();
    return "" + calendar.get(Calendar.YEAR)
            + Utils.formatCalendarIntValue((calendar.get(Calendar.MONTH) + 1), 2)
            + Utils.formatCalendarIntValue(calendar.get(Calendar.DAY_OF_MONTH), 2) + "-"
            + Utils.formatCalendarIntValue(calendar.get(Calendar.HOUR_OF_DAY), 2)
            + Utils.formatCalendarIntValue(calendar.get(Calendar.MINUTE), 2)
            + Utils.formatCalendarIntValue(calendar.get(Calendar.SECOND), 2) + "-"
            + Utils.formatCalendarIntValue(calendar.get(Calendar.MILLISECOND), 3);
}

From source file:com.intuit.wasabi.assignmentobjects.DateHour.java

public void setDateHour(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);/*  w  w  w  .  ja v  a 2  s.c  o m*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    this.day_hour = cal.getTime();
}

From source file:com.wanikani.wklib.UserInformation.java

private static Calendar getNormalizedCalendar(Date date) {
    Calendar ans;// ww w  .  ja  va 2 s  . c  o m

    ans = Calendar.getInstance();
    ans.setTime(date);
    ans.set(Calendar.HOUR, 1);
    ans.set(Calendar.MINUTE, 2);
    ans.set(Calendar.SECOND, 3);
    ans.set(Calendar.MILLISECOND, 4);

    return ans;
}

From source file:Main.java

/**
 * @param date/*from w w  w  . j av  a2s  . c o m*/
 * @return
 */
public static String encodeTime(Date date) {
    StringBuilder result = new StringBuilder("T_");
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);
    int second = cal.get(Calendar.SECOND);
    //yyyy-MM-DD'T'kk:mm:ss
    result.append(year).append("-").append((month < 10) ? "0" : "").append(month).append("-")
            .append((day < 10) ? "0" : "").append(day).append("T").append((hour < 10) ? "0" : "").append(hour)
            .append(":").append((minute < 10) ? "0" : "").append(minute).append(":")
            .append((second < 10) ? "0" : "").append(second);
    return result.toString();
}

From source file:DateUtils.java

public static String getTime() {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());

    int hours = cal.get(Calendar.HOUR_OF_DAY);
    // use 24 hour clock
    int minutes = cal.get(Calendar.MINUTE);
    int seconds = cal.get(Calendar.SECOND);
    int milli = cal.get(Calendar.MILLISECOND);

    return formatTime(hours, minutes, seconds, milli);
}

From source file:com.jennifer.ui.util.TimeUtil.java

public static Date add(Date d, String type, int interval) {
    Calendar c = Calendar.getInstance();
    c.setTime(d);/*from   w  w w  . j av  a  2 s  .  com*/

    if (Time.YEARS.equals(type)) {
        c.add(Calendar.YEAR, interval);
    } else if (Time.MONTHS.equals(type)) {
        c.add(Calendar.MONTH, interval);
    } else if (Time.DAYS.equals(type)) {
        c.add(Calendar.DATE, interval);
    } else if (Time.HOURS.equals(type)) {
        c.add(Calendar.HOUR_OF_DAY, interval);
    } else if (Time.MINUTES.equals(type)) {
        c.add(Calendar.MINUTE, interval);
    } else if (Time.SECONDS.equals(type)) {
        c.add(Calendar.SECOND, interval);
    } else if (Time.MILLISECONDS.equals(type)) {
        c.add(Calendar.MILLISECOND, interval);
    } else if (Time.WEEKS.equals(type)) {
        c.add(Calendar.DATE, interval * 7);
    }

    return c.getTime();
}

From source file:com.my373.common.util.MyDateUtils.java

/**
 * /*from   w w w . java  2  s . co m*/
 * 
 * @param calendar
 * @return
 */
public static Calendar setTimeToMidnight(Calendar calendar) {
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    return calendar;
}