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.calendar.XCalendarExt.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    Calendar calendar = Calendar.getInstance();
    mCallbackContext = callbackContext;//  ww w.  j a  v a  2 s.c o m
    if (COMMAND_GET_TIME.equals(action)) {
        // ???
        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);
    } 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);
    }
    PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
    result.setKeepCallback(true);
    callbackContext.sendPluginResult(result);
    return true;
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleTransferenciaDAOimpl.java

@Override
public List<DetalleTransferencia> getDaily() {
    Criteria criteria = getSession().createCriteria(DetalleTransferencia.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.desc("idDetalleTransferencia"));
    List<DetalleTransferencia> list = criteria.list();
    return list;/*from   w  w  w.ja  v  a  2s . c o  m*/
}

From source file:org.openmrs.module.rwandaprimarycare.AllEncountersController.java

@RequestMapping("/module/rwandaprimarycare/allEncounters")
public String listAllEncounters(@RequestParam("patientId") int patientId, ModelMap model)
        throws PrimaryCareException {

    //LK: Need to ensure that all primary care methods only throw a PrimaryCareException
    //So that errors will be directed to a touch screen error page
    try {/*w w w. j a v  a  2s .  c  o m*/
        Patient patient = Context.getPatientService().getPatient(patientId);
        SortedMap<Date, List<Encounter>> encounters = new TreeMap<Date, List<Encounter>>(
                Collections.reverseOrder());
        for (Encounter e : Context.getEncounterService().getEncountersByPatient(patient)) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(e.getEncounterDatetime());
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
            Date day = cal.getTime();
            List<Encounter> holder = encounters.get(day);
            if (holder == null) {
                holder = new ArrayList<Encounter>();
                encounters.put(day, holder);
            }
            holder.add(e);
        }
        model.addAttribute("patient", patient);
        model.addAttribute("encounters", encounters);
        model.addAttribute("vitalsEncounterType", PrimaryCareBusinessLogic.getVitalsEncounterType());
        model.addAttribute("registrationEncounterType",
                PrimaryCareBusinessLogic.getRegistrationEncounterType());
    } catch (Exception e) {
        throw new PrimaryCareException(e);
    }
    return "/module/rwandaprimarycare/allEncounters";
}

From source file:org.kuali.coeus.s2sgen.impl.datetime.S2SDateTimeServiceImpl.java

/**
 *
 * This method computes the number of months between any 2 given {@link java.sql.Date} objects
 *
 * @param dateStart starting date.//from   w  w  w.  ja  va2s.c  om
 * @param dateEnd end date.
 *
 * @return number of months between the start date and end date.
 */
@Override
public ScaleTwoDecimal getNumberOfMonths(java.util.Date dateStart, java.util.Date dateEnd) {
    ScaleTwoDecimal monthCount = ScaleTwoDecimal.ZERO;
    int fullMonthCount = 0;

    Calendar startDate = Calendar.getInstance();
    Calendar endDate = Calendar.getInstance();
    startDate.setTime(dateStart);
    endDate.setTime(dateEnd);

    startDate.clear(Calendar.HOUR);
    startDate.clear(Calendar.MINUTE);
    startDate.clear(Calendar.SECOND);
    startDate.clear(Calendar.MILLISECOND);

    endDate.clear(Calendar.HOUR);
    endDate.clear(Calendar.MINUTE);
    endDate.clear(Calendar.SECOND);
    endDate.clear(Calendar.MILLISECOND);

    if (startDate.after(endDate)) {
        return ScaleTwoDecimal.ZERO;
    }
    int startMonthDays = startDate.getActualMaximum(Calendar.DATE) - startDate.get(Calendar.DATE);
    startMonthDays++;
    int startMonthMaxDays = startDate.getActualMaximum(Calendar.DATE);
    BigDecimal startMonthFraction = BigDecimal.valueOf(startMonthDays).setScale(2, RoundingMode.HALF_UP).divide(
            BigDecimal.valueOf(startMonthMaxDays).setScale(2, RoundingMode.HALF_UP), RoundingMode.HALF_UP);

    int endMonthDays = endDate.get(Calendar.DATE);
    int endMonthMaxDays = endDate.getActualMaximum(Calendar.DATE);

    BigDecimal endMonthFraction = BigDecimal.valueOf(endMonthDays).setScale(2, RoundingMode.HALF_UP).divide(
            BigDecimal.valueOf(endMonthMaxDays).setScale(2, RoundingMode.HALF_UP), RoundingMode.HALF_UP);

    startDate.set(Calendar.DATE, 1);
    endDate.set(Calendar.DATE, 1);

    while (startDate.getTimeInMillis() < endDate.getTimeInMillis()) {
        startDate.set(Calendar.MONTH, startDate.get(Calendar.MONTH) + 1);
        fullMonthCount++;
    }
    fullMonthCount = fullMonthCount - 1;
    monthCount = monthCount.add(new ScaleTwoDecimal(fullMonthCount))
            .add(new ScaleTwoDecimal(startMonthFraction)).add(new ScaleTwoDecimal(endMonthFraction));
    return monthCount;
}

From source file:DateTimeUtil.java

/** Convert given date to string<br>
 *  OutputFormat: yyyymmdd_hhmm/*  w  w  w.java 2 s.c  o m*/
 *  @return The Date/Time in the format: yyyymmdd_hhmm
 */
public static String convertToDateStamp(Calendar cal) {
    String year = String.valueOf(cal.get(Calendar.YEAR));
    String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
    if (month.length() == 1) {
        month = "0" + month;
    }
    String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
    if (day.length() == 1) {
        day = "0" + day;
    }
    String hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
    if (hour.length() == 1) {
        hour = "0" + hour;
    }
    String minute = String.valueOf(cal.get(Calendar.MINUTE));
    if (minute.length() == 1) {
        minute = "0" + minute;
    }
    String second = String.valueOf(cal.get(Calendar.SECOND));
    if (second.length() == 1) {
        second = "0" + second;
    }
    String dateStamp = year + month + day + "_" + hour + minute + second;
    return dateStamp;
}

From source file:Main.java

/**
 * <p>Checks if two calendar objects represent the same local time.</p>
 *
 * <p>This method compares the values of the fields of the two objects.
 * In addition, both calendars must be the same of the same type.</p>
 * //from   w  w w .  j a  v a 2s  . c o  m
 * @param cal1  the first calendar, not altered, not null
 * @param cal2  the second calendar, not altered, not null
 * @return true if they represent the same millisecond instant
 * @throws IllegalArgumentException if either date is <code>null</code>
 * @since 2.1
 */
public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) {
    if (cal1 == null || cal2 == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND)
            && cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND)
            && cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)
            && cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR)
            && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
            && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
            && cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) && cal1.getClass() == cal2.getClass());
}

From source file:io.gatling.jenkins.targetenvgraphs.BuildInfoForTargetEnvGraph.java

public Calendar getGraphStartTime() {
    Calendar graphStartTime = (Calendar) getBuildStartTime().clone();
    graphStartTime.add(Calendar.MINUTE, GRAPH_START_BUFFER_TIME_IN_MINUTES);
    return graphStartTime;
}

From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java

protected static Calendar prepareCalendar(int year, int month, int day, int hour, int minute, int second,
        int millisecond) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MILLISECOND, millisecond);
    calendar.set(Calendar.SECOND, second);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.DATE, day);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.YEAR, year);
    return calendar;
}

From source file:com.sirma.itt.emf.time.ISO8601DateFormat.java

/**
 * Format calendar instance into ISO format.
 * /*from   w  w w  . j a  v a  2s  .  co m*/
 * @param calendar
 *            the calendar instance to format
 * @return the ISO formatted string
 */
public static String format(Calendar calendar) {
    if (calendar == null) {
        return null;
    }

    StringBuilder formatted = new StringBuilder(28);
    padInt(formatted, calendar.get(Calendar.YEAR), 4);
    formatted.append('-');
    padInt(formatted, calendar.get(Calendar.MONTH) + 1, 2);
    formatted.append('-');
    padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), 2);
    formatted.append('T');
    padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), 2);
    formatted.append(':');
    padInt(formatted, calendar.get(Calendar.MINUTE), 2);
    formatted.append(':');
    padInt(formatted, calendar.get(Calendar.SECOND), 2);
    formatted.append('.');
    padInt(formatted, calendar.get(Calendar.MILLISECOND), 3);

    TimeZone tz = calendar.getTimeZone();
    int offset = tz.getOffset(calendar.getTimeInMillis());
    formatted.append(getTimeZonePadding(offset));

    return formatted.toString();
}

From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java

@Test
public void testParseTimestamp() {
    FTPFileEntryParser parser = new FTPParserSelector().getParser("UNIX");

    FTPFile parsed;/*from   w  w  w .  jav  a 2s.c om*/

    parsed = parser
            .parseFTPEntry("drw-rw-rw-   1 user      ftp             0  DEC 11 20:56 ADMIN_Documentation");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(11, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(20, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY));
    assertEquals(56, parsed.getTimestamp().get(Calendar.MINUTE));

    parsed = parser.parseFTPEntry("drwxr-xr-x    3 ftp      ftp           512 Mar 15  2004 doc");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(2004, parsed.getTimestamp().get(Calendar.YEAR));
    assertEquals(Calendar.MARCH, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));

    parsed = parser.parseFTPEntry("drwxrwxr-x    2 ftp      ftp           512 Oct 23  2007 aurox");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(2007, parsed.getTimestamp().get(Calendar.YEAR));
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(23, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
}