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:ISO8601DateFormat.java

/**
 * @see java.text.DateFormat#parse(String, ParsePosition)
 *//*w ww  .  j  a  v  a 2 s  .c o  m*/
public Date parse(String text, ParsePosition pos) {

    int i = pos.getIndex();

    try {
        int year = Integer.valueOf(text.substring(i, i + 4)).intValue();
        i += 4;

        if (text.charAt(i) != '-') {
            throw new NumberFormatException();
        }
        i++;

        int month = Integer.valueOf(text.substring(i, i + 2)).intValue() - 1;
        i += 2;

        if (text.charAt(i) != '-') {
            throw new NumberFormatException();
        }
        i++;

        int day = Integer.valueOf(text.substring(i, i + 2)).intValue();
        i += 2;

        calendar.set(year, month, day);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0); // no parts of a second

        i = parseTZ(i, text);

    } catch (NumberFormatException ex) {
        pos.setErrorIndex(i);
        return null;
    } catch (IndexOutOfBoundsException ex) {
        pos.setErrorIndex(i);
        return null;
    } finally {
        pos.setIndex(i);
    }

    return calendar.getTime();
}

From source file:com.hemou.android.util.StrUtils.java

/**
 * {@link https://en.wikipedia.org/wiki/List_of_time_zones_by_country}
 * @param time/*from w ww  .  j a  va  2s.c om*/
 * @return
 */
public static String convertTimeWithTimeZome(long time) {

    Calendar cal = Calendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("UTC"));
    cal.setTimeInMillis(time);
    return (cal.get(Calendar.YEAR) + " " + (cal.get(Calendar.MONTH) + 1) + " " + cal.get(Calendar.DAY_OF_MONTH)
            + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));

}

From source file:ro.bmocanu.tests.ws.springws.server.ProductServiceMarshallingPayloadEndpoint.java

@SuppressWarnings("restriction")
protected Object invokeInternal(Object request) throws Exception {
    ObjectFactory objectFactory = new ObjectFactory();

    GetProductByIdRequest gpbiRequest = (GetProductByIdRequest) request;
    long productId = gpbiRequest.getProductId();
    Product product = ProductManager.singleInstance.getProductById(productId);

    XMLGregorianCalendar cal = new com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl();
    Calendar c = Calendar.getInstance();
    cal.setTime(c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND));

    GetProductByIdResponse gpbiResponse = objectFactory.createGetProductByIdResponse();

    ProductType xmlProduct = objectFactory.createProductType();
    xmlProduct.setId(product.getId());/*ww  w .  java 2 s.  c o  m*/
    xmlProduct.setName(product.getName());
    xmlProduct.setDescription(product.getDescription());
    xmlProduct.setReceived(cal);

    gpbiResponse.setProduct(xmlProduct);

    return gpbiResponse;
}

From source file:org.openmrs.module.uiframeworkpatientsummarysupport.fragment.controller.PatientObsFlowsheetFragmentController.java

/**
 * This method was actually added in core as of 1.9
 *///from  w w  w. jav  a  2s . co  m
private static Date startOfDay(Date date) {
    if (date == null)
        return null;

    Calendar c = Calendar.getInstance();
    c.setTime(date);
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);

    return c.getTime();
}

From source file:gov.nih.nci.cabig.ctms.audit.dao.AuditHistoryRepository.java

/**
 * Checks if entity was created minutes before the specefied date.
 * By default method will check if entity was created one minute before the given data
 *
 * @param entityClass the entity class//  w  w w  . j a  va2  s .c om
 * @param entityId    the primary key of entity
 * @param calendar    the date
 * @param minutes     time before the entity was created
 * @return true if entity was created minutes before the specefied date.
 * @throws IllegalArgumentException if all the parameter except minutes is null;
 */
public boolean checkIfEntityWasCreatedMinutesBeforeSpecificDate(final Class entityClass, final Integer entityId,
        final Calendar calendar, int minutes)

{

    if (calendar == null || entityClass == null || entityId == null) {
        throw new IllegalArgumentException("invalid uses of method. All method parameters must not be null");
    }
    if (Integer.valueOf(minutes).equals(Integer.valueOf(0))) {
        minutes = 1;
    }
    final Calendar newCalendar = (Calendar) calendar.clone();
    newCalendar.add(Calendar.MINUTE, -minutes);
    DataAuditEventQuery dataAuditEventQuery = new DataAuditEventQuery();
    dataAuditEventQuery.filterByClassName(entityClass.getName());
    dataAuditEventQuery.filterByStartDateAfter(newCalendar.getTime());
    dataAuditEventQuery.filterByEndDateBefore(calendar.getTime());
    dataAuditEventQuery.filterByEntityId(entityId);
    dataAuditEventQuery.filterByOperation(Operation.CREATE);
    final List<DataAuditEvent> dataAuditEvents = auditHistoryDao.findDataAuditEvents(dataAuditEventQuery);
    return dataAuditEvents != null && !dataAuditEvents.isEmpty();

}

From source file:be.fedict.eid.pkira.common.util.FilterHelperBean.java

private Date changeTime(Date date, int hours, int minutes, int seconds) {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);/*from ww  w .  j  a  v  a 2s.  com*/
    calendar.set(Calendar.HOUR, hours);
    calendar.set(Calendar.MINUTE, minutes);
    calendar.set(Calendar.SECOND, seconds);

    return calendar.getTime();
}

From source file:net.seratch.taskun.util.CalendarUtil.java

 public static Calendar getCalendar(String yyyy, String mm, String dd,
      String hh, String mi, String ss) {
   Calendar cal = getCalendar(yyyy, mm, dd);
   cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hh));
   cal.set(Calendar.MINUTE, Integer.valueOf(mi));
   cal.set(Calendar.SECOND, Integer.valueOf(ss));
   return cal;/*from w w  w  . ja v a2s .  c om*/
}

From source file:cognitivabrasil.obaa.Technical.Duration.java

/**
 *
 * @param value The value of the field//w w  w . ja  v  a2s .  co  m
 * @param field The Java Calendar constant that reprensents the field, need
 * to be Calendar.HOUR, Calendar.MINUTE or Calendar.SECOND
 */
public void set(int value, int field) {
    if (field == Calendar.HOUR) {
        hours = value;
    }
    if (field == Calendar.MINUTE) {
        minutes = value;
    }
    if (field == Calendar.SECOND) {
        seconds = value;
    }

    StringBuilder builder = new StringBuilder("PT");

    if (hours != 0) {
        builder.append(hours);
        builder.append("H");
    }

    if (minutes != 0) {
        builder.append(minutes);
        builder.append("M");
    }

    if (seconds != 0) {
        builder.append(seconds);
        builder.append("S");
    }

    super.setText(builder.toString());
}

From source file:XSDDateTime.java

public static String getDateTime(Calendar cal) {
    if (!cal.getTimeZone().equals(TimeZone.getTimeZone("GMT+00:00"))) {
        throw new InvalidParameterException();
    }/*w ww  . ja va 2  s.c  om*/
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    month++;
    String monthString = pad(month);
    int day = cal.get(Calendar.DAY_OF_MONTH);
    String dayString = pad(day);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    String hourString = pad(hour);
    int minutes = cal.get(Calendar.MINUTE);
    String minutesString = pad(minutes);
    int seconds = cal.get(Calendar.SECOND);
    String secondsString = pad(seconds);

    return year + "-" + monthString + "-" + dayString + "T" + hourString + ":" + minutesString + ":"
            + secondsString + "Z";
}

From source file:com.amazonaws.services.ec2.util.S3UploadPolicy.java

/**
 * Creates a new S3 upload policy object from the specified parameters. Once
 * constructed, callers can access the policy string and policy signature to
 * use with the EC2 bundling API.//ww  w  . ja v a  2s  . c om
 *
 * @param awsAccessKeyId
 *            The AWS access key ID for the S3 bucket the bundling artifacts
 *            should be stored in.
 * @param awsSecretKey
 *            The AWS secret key for the specified access key.
 * @param bucketName
 *            The name of the bucket to store the bundling artifacts in.
 * @param prefix
 *            The prefix for the bundling artifacts.
 * @param expireInMinutes
 *            The number of minutes before the upload policy expires and is
 *            unable to be used.
 */
public S3UploadPolicy(String awsAccessKeyId, String awsSecretKey, String bucketName, String prefix,
        int expireInMinutes) {
    Calendar expirationDate = Calendar.getInstance();
    expirationDate.add(Calendar.MINUTE, expireInMinutes);
    SimpleDateFormat ISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    ISO8601.setTimeZone(new SimpleTimeZone(0, "GMT"));
    StringBuilder builder = new StringBuilder();
    builder.append("{").append("\"expiration\": \"").append(ISO8601.format(expirationDate.getTime()))
            .append("\",").append("\"conditions\": [").append("{\"bucket\": \"").append(bucketName)
            .append("\"},").append("{\"acl\": \"").append("ec2-bundle-read").append("\"},")
            .append("[\"starts-with\", \"$key\", \"").append(prefix).append("\"]").append("]}");
    try {
        this.policyString = base64Encode(builder.toString().getBytes("UTF-8"));
        this.policySignature = signPolicy(awsSecretKey, policyString);
    } catch (Exception ex) {
        throw new RuntimeException("Unable to generate S3 upload policy", ex);
    }
}