Example usage for java.util GregorianCalendar getTimeInMillis

List of usage examples for java.util GregorianCalendar getTimeInMillis

Introduction

In this page you can find the example usage for java.util GregorianCalendar getTimeInMillis.

Prototype

public long getTimeInMillis() 

Source Link

Document

Returns this Calendar's time value in milliseconds.

Usage

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithDateArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Date dateValue = config.dateArray[0];

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50);

    Date date = new Date(calendar.getTimeInMillis());

    assertEquals(Date.class, dateValue.getClass());
    assertEquals(date.getTime(), dateValue.getTime());
    assertEquals(3, config.dateArray.length);
}

From source file:org.openmrs.module.pmtct.PregnancyDateManager.java

@SuppressWarnings("deprecation")
public String getNumberOfWeeks(String dateOfPeriod) throws Exception {
    Date lastDateOfPeriod = Context.getDateFormat().parse(dateOfPeriod);

    GregorianCalendar last_DateOfPeriod = new GregorianCalendar(lastDateOfPeriod.getYear(),
            lastDateOfPeriod.getMonth(), lastDateOfPeriod.getDate());
    last_DateOfPeriod.setLenient(false);

    Date da = new Date();

    //      slog.info("xxxxxxxxxxxxxxx"+(new GregorianCalendar(da.getYear()+1900,da.getMonth(),da.getDate())).getTime());

    //1 week=604800000 milliseconds = (1000ms*60s*60min*24h*7days)

    return "**********************"
            + (((new GregorianCalendar(da.getYear(), da.getMonth(), da.getDate())).getTimeInMillis())
                    - (last_DateOfPeriod.getTimeInMillis())) / 604800000;
}

From source file:TimePeriod.java

/**
 * Erhht den Von-Wert um einen Tag und prft, ob es sich dabei dann um
 * heute handelt./*from   w  ww .  j a  va 2s . c  o m*/
 */
public void setToPlusOneDay() {
    to.setTimeInMillis(to.getTimeInMillis() + ONE_DAY);
    GregorianCalendar heute = new GregorianCalendar();
    set2359(heute);
    if (to.getTimeInMillis() == heute.getTimeInMillis())
        to_typ = TODAY;
    else
        to_typ = -1;
    // Bis darf nicht vor von liegen! Falls es doch der Fall sein sollte,
    // wird auch von angepasst
    if (to.before(from)) {
        from.setTimeInMillis(to.getTimeInMillis());
        setMidnight(from);
    }
}

From source file:TimePeriod.java

/**
 * Erniedrigt den Von-Wert um einen Tag und prft, ob es sich dabei dann um
 * heute handelt./*from  w w  w.  j a  va2  s  .c  om*/
 */
public void setToMinusOneDay() {
    to.setTimeInMillis(to.getTimeInMillis() - ONE_DAY);
    GregorianCalendar heute = new GregorianCalendar();
    set2359(heute);
    if (to.getTimeInMillis() == heute.getTimeInMillis())
        to_typ = TODAY;
    else
        to_typ = -1;
    // Bis darf nicht vor von liegen! Falls es doch der Fall sein sollte,
    // wird auch von angepasst
    if (to.before(from)) {
        from.setTimeInMillis(to.getTimeInMillis());
        setMidnight(from);
        from_typ = to_typ;
    }
}

From source file:TimePeriod.java

/**
 * Erniedrigt den Von-Wert um einen Tag und prft, ob es sich dabei dann um
 * heute handelt.//from w w w  . j  a  v a 2s  .c  om
 */
public void setFromMinusOneDay() {
    from.setTimeInMillis(from.getTimeInMillis() - ONE_DAY);
    GregorianCalendar heute = new GregorianCalendar();
    setMidnight(heute);
    if (from.getTimeInMillis() == heute.getTimeInMillis())
        from_typ = TODAY;
    else
        from_typ = -1;
    if (to.before(from)) {
        to.setTimeInMillis(from.getTimeInMillis());
        set2359(to);
        to_typ = from_typ;
    }
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithCalendarList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Calendar calendarValue = config.calendarList.get(0);

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarList.size());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithCalendarList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Calendar calendarValue = config.calendarList.get(0);

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarList.size());
}

From source file:TimePeriod.java

/**
 * Erhht den Von-Wert um einen Tag und prft, ob es sich dabei dann um
 * heute handelt./*from   w  w w  . j  a  v a  2  s.c  om*/
 */
public void setFromPlusOneDay() {
    from.setTimeInMillis(from.getTimeInMillis() + ONE_DAY);
    GregorianCalendar heute = new GregorianCalendar();
    setMidnight(heute);
    if (from.getTimeInMillis() == heute.getTimeInMillis())
        from_typ = TODAY;
    else
        from_typ = -1;
    // Bis darf nicht vor von liegen! Falls es doch der Fall sein sollte,
    // wird auch bis angepasst
    if (to.before(from)) {
        to.setTimeInMillis(from.getTimeInMillis());
        set2359(to);
        to_typ = from_typ;
    }
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithCalendarArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Calendar calendarValue = config.calendarArray[0];

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithCalendarArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Calendar calendarValue = config.calendarArray[0];

    GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10);

    assertEquals(Calendar.class, calendarValue.getClass().getSuperclass());
    assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis());
    assertEquals(3, config.calendarArray.length);
}