Example usage for java.util Calendar MINUTE

List of usage examples for java.util Calendar MINUTE

Introduction

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

Prototype

int MINUTE

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

Click Source Link

Document

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

Usage

From source file:com.polyvi.xface.extension.XCalendarExt.java

@Override
public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException {

    Calendar calendar = Calendar.getInstance();

    if (COMMAND_GET_TIME.equals(action)) {
        // ???/*  www . j ava2s. co  m*/
        int hours = calendar.get(Calendar.HOUR_OF_DAY);
        int minutes = calendar.get(Calendar.MINUTE);

        if (2 == args.length()) {
            hours = args.getInt(0);
            minutes = args.getInt(1);
        }

        getTime(hours, minutes, callbackCtx);
    } else if (COMMAND_GET_DATE.equals(action)) {
        // ???
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);

        if (3 == args.length()) {
            year = args.getInt(0);
            month = args.getInt(1);
            day = args.getInt(2);
        }

        getDate(year, month, day, callbackCtx);
    }

    XExtensionResult er = new XExtensionResult(XExtensionResult.Status.NO_RESULT);
    return er;
}

From source file:es.tekniker.framework.ktek.util.Utils.java

public static long getTimeinMillis4FullDateTimeGMT(int year, int month, int day, int hours, int minutes,
        int seconds) {
    Calendar c = getCalendarGMT();

    c.set(Calendar.YEAR, year);//from  w  w  w  .  j  ava 2  s .c om
    c.set(Calendar.MONTH, month);
    c.set(Calendar.DAY_OF_MONTH, day);

    c.set(Calendar.HOUR_OF_DAY, hours);
    c.set(Calendar.MINUTE, minutes);
    c.set(Calendar.SECOND, seconds);

    System.out.println("New Time: " + c.getTime());

    long timeinmillis = c.getTimeInMillis();
    System.out.println(" system time in millis " + timeinmillis);

    return timeinmillis;
}

From source file:com.fluke.util.Util.java

public static String getTime(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);//  w w  w  .  ja v a  2s  . c o  m
    return calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE);

}

From source file:com.lfv.yada.net.server.ServerLogger.java

public ServerLogger(int groupId, String logpath) {
    // Create a logger for this class
    if (logpath == null) {
        logpath = "data/logs/";
    }//from   w  ww.  jav  a  2s .c  o m
    mylogpath = logpath;
    log = LogFactory.getLog(getClass());
    log.info("ServerLogger: logpath=" + logpath);

    // Create a calendar
    startTime = System.currentTimeMillis();
    calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    calendar.setTimeInMillis(startTime);
    String filename = "Grp" + groupId + "-" + calendar.get(Calendar.YEAR) + s2(calendar.get(Calendar.MONTH) + 1)
            + s2(calendar.get(Calendar.DAY_OF_MONTH)) + "-" + s2(calendar.get(Calendar.HOUR_OF_DAY))
            + s2(calendar.get(Calendar.MINUTE)) + s2(calendar.get(Calendar.SECOND)) + ".log";
    try {
        printer = new PrintStream(new FileOutputStream(logpath + "/" + filename), true);

        log.info("Creating log " + logpath + "/" + filename);
    } catch (FileNotFoundException ex) {
        log.warn("Log file " + filename + " could not be created, logger has been disabled!", ex);
        printer = null;
    }
}

From source file:com.prey.json.actions.Report.java

public boolean valida(Context ctx) {
    long lastReportStartDate = PreyConfig.getPreyConfig(ctx).getLastReportStartDate();
    PreyLogger.d("last:" + lastReportStartDate);
    if (lastReportStartDate != 0) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(lastReportStartDate);
        cal.add(Calendar.MINUTE, 1);
        long timeMore = cal.getTimeInMillis();
        PreyLogger.d("timM:" + timeMore);
        Date nowDate = new Date();
        long now = nowDate.getTime();
        PreyLogger.d("now_:" + now);
        PreyLogger.d("now>=timeMore:" + (now >= timeMore));
        return (now >= timeMore);
    }//w  w  w . j  a va  2  s.  com
    return true;
}

From source file:frk.gpssimulator.service.impl.DefaultGpsdService.java

@Override
public void updatePosition(PositionInfo position) {

    // an NMEA RMC position sentence (report) is of form:
    // $GPRMC,124426,A,5920.7019,N,02803.2893,E,,,121212,,

    Calendar cal = Calendar.getInstance();
    Integer hour = cal.get(Calendar.HOUR_OF_DAY);
    Integer minute = cal.get(Calendar.MINUTE);
    Integer second = cal.get(Calendar.SECOND);
    Integer date = cal.get(Calendar.DATE);
    Integer month = cal.get(Calendar.MONTH) + 1; // java Calendar month
    // starts at 0
    Integer year = cal.get(Calendar.YEAR) % 100; // convert to 2 digit year

    String sHour = String.format("%02d", hour);
    String sMinute = String.format("%02d", minute);
    String sSecond = String.format("%02d", second);
    String sDate = String.format("%02d", date);
    String sMonth = String.format("%02d", month);
    String sYear = String.format("%02d", year);

    String sentence = null;/*ww w . ja  v  a  2s .co  m*/
    if (position == null) {
        sentence = "$GPRMC," + sHour + sMinute + sSecond + ",A,,,,,,," + sDate + sMonth + sYear + ",,";
    } else {
        double lat = position.getPosition().getLatitude();
        double lon = position.getPosition().getLongitude();

        String latSuffix = "N";
        if (lat < 0) {
            latSuffix = "S";
        }
        lat = Math.abs(lat);
        String lonSuffix = "E";
        if (lon < 0) {
            lonSuffix = "W";
        }
        lon = Math.abs(lon);

        long latDeg = (long) lat; // degree part
        double latMin = (lat - latDeg) * 60; // minute part
        long latMinWhole = (long) latMin; // whole part of minute
        Double latMinFrac = latMin - latMinWhole; // fractional part of
        // minute
        String sLatDeg = String.format("%02d", latDeg);
        String sLatMinWhole = String.format("%02d", latMinWhole);
        String sLatMinFrac = latMinFrac.toString().replace("0.", ".");
        long lonDeg = (long) lon; // degree part
        double lonMin = (lon - lonDeg) * 60; // minute part
        long lonMinWhole = (long) lonMin; // whole part of minute
        Double lonMinFrac = lonMin - lonMinWhole; // fractional part of
        // minute
        String sLonDeg = String.format("%02d", lonDeg);
        String sLonMinWhole = String.format("%02d", lonMinWhole);
        String sLonMinFrac = lonMinFrac.toString().replace("0.", ".");

        sentence = "$GPRMC," + sHour + sMinute + sSecond + ",A," + sLatDeg + sLatMinWhole + sLatMinFrac + ","
                + latSuffix + "," + sLonDeg + sLonMinWhole + sLonMinFrac + "," + lonSuffix + ",,," + sDate
                + sMonth + sYear + ",,";
    }

    try {
        pipeWriter.write(sentence + "\r\n");
        pipeWriter.flush();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:org.openmrs.module.openconceptlab.scheduler.UpdateScheduler.java

@SuppressWarnings("unchecked")
public synchronized void schedule(Subscription subscription) {
    updateService.saveSubscription(subscription);

    if (scheduledUpdate != null) {
        scheduledUpdate.cancel(false);//  www  . j  a v a 2  s .  co  m
    }

    if (subscription.getDays() != 0 || subscription.getHours() != 0 || subscription.getMinutes() != 0) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, subscription.getHours());
        calendar.set(Calendar.MINUTE, subscription.getMinutes());
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        scheduledUpdate = scheduler.scheduleAtFixedRate(updater, calendar.getTime(),
                subscription.getDays() * DAY_PERIOD);
    }
}

From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsLoggingDao.java

/**
 * Get a {@link Date}, where hours, minutes, seconds and milliseconds are
 * set to 0./*from  w w w . j ava  2 s. co  m*/
 *
 * @return the {@link Date} .
 */
private static Date getDayEnd(final Date d) {
    final Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE);
    gc.setTime(d);
    gc.set(Calendar.HOUR_OF_DAY, 23);
    gc.set(Calendar.MINUTE, 59);
    gc.set(Calendar.SECOND, 59);
    gc.set(Calendar.MILLISECOND, 0);
    return gc.getTime();
}

From source file:com.autentia.common.util.DateFormater.java

public static Date normalizeEndDate(Date date) {

    GregorianCalendar gCalendar = new GregorianCalendar();
    gCalendar.setTime(date);//from w  ww .  j  av  a  2  s. c  o  m
    gCalendar.set(Calendar.HOUR_OF_DAY, 23);
    gCalendar.set(Calendar.MINUTE, 59);
    gCalendar.set(Calendar.SECOND, 59);
    gCalendar.set(Calendar.MILLISECOND, 999);

    return gCalendar.getTime();
}

From source file:com.linuxbox.enkive.teststats.StatsHourGrainTest.java

@SuppressWarnings("unchecked")
@BeforeClass/*  w w  w.j  a va2s . c o m*/
public static void setUp() throws ParseException, GathererException {
    gatherTester = TestHelper.BuildGathererService();
    coll = TestHelper.GetTestCollection();
    client = TestHelper.BuildClient();
    grain = new HourConsolidator(client);

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.MILLISECOND, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MINUTE, 0);
    for (int i = 0; i < 10; i++) {
        List<RawStats> stats = gatherTester.gatherStats();
        List<Map<String, Object>> statsToStore = createListOfMaps();
        if (i == 5) {
            cal.add(Calendar.HOUR, -1);
        }

        for (RawStats data : stats) {
            Map<String, Object> temp = data.toMap();
            Map<String, Object> date = (Map<String, Object>) temp.get(STAT_TIMESTAMP);
            date.put(CONSOLIDATION_MIN, cal.getTime());
            date.put(CONSOLIDATION_MAX, cal.getTime());
            date.put(STAT_TS_POINT, cal.getTime());
            statsToStore.add(temp);
        }
        client.storeData(statsToStore);
    }
    dataCount = coll.count();
}