Example usage for java.util GregorianCalendar getTime

List of usage examples for java.util GregorianCalendar getTime

Introduction

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

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:launcher.multithread.Extract.java

/**
 * Starts/*from   w w w .  j  a  v  a2 s .  c om*/
 */
protected void go() {
    GenericObjectPool pool = new GenericObjectPool(new ExtractorFactory());
    pool.setMaxActive(15);
    // wait forever
    pool.setMaxWait(-1);

    // hacktastic ;o)
    /*
    int[] rapIds = {218,67,92,26,497,374,1858,1039,429,716};      
    for(int i=0; i<rapIds.length; i++) {
       int rapId = rapIds[i];
    */
    for (int rapId = 0; rapId < 2000; rapId++) {

        // these have been done... 
        if (rapId == 218 || rapId == 67 || rapId == 92 || rapId == 26 || rapId == 497 || rapId == 374
                || rapId == 1858 || rapId == 1039 || rapId == 429 || rapId == 716) {
            continue;
        }

        logger.info("Queing up Id: " + rapId);
        SequenceProcessor workflow = (SequenceProcessor) context.getBean("GBIF:INDEX:1.0:extractOccurrence");
        Map<String, Object> seed = new HashMap<String, Object>();
        GregorianCalendar cal = new GregorianCalendar();
        cal.add(Calendar.MONTH, -6);
        seed.put("pageFrom", cal.getTime());
        seed.put("resourceAccessPointId", new Long(rapId));
        Thread t = new Thread(new Runner(seed, workflow, pool));
        t.start();
    }
}

From source file:org.eurekastreams.server.action.execution.notification.DeleteOldApplicationAlertsExecution.java

/**
 * {@inheritDoc} This method calls the database mapper to delete application alerts that are older than ageInDays.
 * Before the delete, a mapper call is made to find which users had old unread alerts then after the actual
 * deletion, the cached count of unread alerts for these users is synced with the database.
 *//*  www  .j  av a2  s . c o  m*/
@Override
public Serializable execute(final ActionContext inActionContext) {
    if (log.isInfoEnabled()) {
        log.info("Deleting application alerts older than " + ageInDays + " days");
    }

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(GregorianCalendar.DATE, ageInDays * -1);
    Date oldDate = calendar.getTime();

    List<Long> userIdsToSync = unreadMapper.execute(oldDate);

    deleteMapper.execute(oldDate);

    for (long userId : userIdsToSync) {
        syncMapper.execute(userId);
    }

    return true;
}

From source file:org.openvpms.archetype.util.DateRulesTestCase.java

/**
 * Tests the {@link DateRules#getTomorrow()} method.
 *///from w  w  w  .j  a va 2 s.  c o m
@Test
public void testGetTomorrow() {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(new Date());
    calendar.add(Calendar.DAY_OF_MONTH, 1);

    Date expected = DateUtils.truncate(calendar.getTime(), Calendar.DAY_OF_MONTH);
    assertEquals(expected, DateRules.getTomorrow());
}

From source file:org.openmrs.module.drughistory.api.DrugEventServiceTest.java

@Test
@ExpectedException(IllegalArgumentException.class)
public void generateAllDrugEvents_shouldThrowExceptionIfSinceWhenIsGreaterThanToday() throws Exception {
    GregorianCalendar gc = new GregorianCalendar();
    gc.add(GregorianCalendar.DAY_OF_MONTH, 1);
    Date sinceWhen = gc.getTime();
    Context.getService(DrugEventService.class).generateAllDrugEvents(sinceWhen);
}

From source file:org.openmrs.module.drughistory.api.DrugEventServiceTest.java

/**
 * @verifies generate drug events with obs datetime later than or equal to sinceWhen
 * @see DrugEventService#generateDrugEventsFromTrigger(org.openmrs.module.drughistory.DrugEventTrigger, java.util.Date)
 *///from w  w  w .ja v  a  2  s  .  c  o  m
@Test
public void generateDrugEventsFromTrigger_shouldGenerateDrugEventsWithObsDatetimeLaterThanOrEqualToSinceWhen()
        throws Exception {
    GregorianCalendar gc = new GregorianCalendar(2008, 7, 19); //Months start from 0 in GC.
    Date sinceWhen = gc.getTime();

    Concept q = Context.getConceptService().getConcept(5089);

    DrugEventTrigger trigger = new DrugEventTrigger();
    trigger.addQuestion(q);
    trigger.setEventConcept(q);
    trigger.setEventType(DrugEventType.CONTINUE);
    drugEventService.generateDrugEventsFromTrigger(trigger, sinceWhen);

    List<DrugEvent> drugEvents = drugEventService.getAllDrugEvents(null);
    Assert.assertEquals(1, (long) drugEvents.size());

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Assert.assertEquals(dateFormat.format(gc.getTime()),
            dateFormat.format(drugEvents.get(0).getDateOccurred()));
}

From source file:com.owly.srv.RemoteBasicStat.java

/**
 * Constructor for RemoteBasicStat/*from  ww  w . j  ava 2  s .  c  o m*/
 */
public RemoteBasicStat() {
    Logger log = Logger.getLogger(RemoteBasicStat.class);

    log.debug("Calling RemoteBasicStat constructor");

    GregorianCalendar currentDate = new GregorianCalendar();
    statServerDate = currentDate.getTime();

    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    log.debug("Actual date is " + dateFormat.format(statServerDate));
}

From source file:com.adwhirl.adapters.QuattroAdapter.java

public void onAdRequest(Context context, AdRequestParams params) {
    if (params != null) {
        params.setTestMode(AdWhirlTargeting.getTestMode());

        final AdWhirlTargeting.Gender gender = AdWhirlTargeting.getGender();
        if (gender == AdWhirlTargeting.Gender.FEMALE) {
            params.setGender(com.qwapi.adclient.android.requestparams.Gender.female);
        } else if (gender == AdWhirlTargeting.Gender.MALE) {
            params.setGender(com.qwapi.adclient.android.requestparams.Gender.male);
        }/*from w w w  .  j av a 2 s.  c om*/

        final GregorianCalendar birthDate = AdWhirlTargeting.getBirthDate();
        if (birthDate != null) {
            params.setBirthDate(birthDate.getTime());
        }

        final String postalCode = AdWhirlTargeting.getPostalCode();
        if (!TextUtils.isEmpty(postalCode)) {
            params.setZipCode(postalCode);
        }
    }
}

From source file:org.nuxeo.ecm.platform.jbpm.TaskListImpl.java

@SuppressWarnings("unchecked")
public List<VirtualTaskInstance> getTasks() {
    try {/*from  w w w  .j  a  v  a  2s. c  om*/
        List<VirtualTaskInstance> mls = new ArrayList<VirtualTaskInstance>();
        List<Map<String, Object>> participants = (List<Map<String, Object>>) doc.getPropertyValue("ntl:tasks");

        if (participants != null) {
            for (Map<String, Object> participant : participants) {
                VirtualTaskInstance task = new VirtualTaskInstance();
                task.setActors((List<String>) participant.get("taskUsers"));
                task.setDirective((String) participant.get("directive"));
                task.setComment((String) participant.get("comment"));
                if (participant.containsKey("right")) {
                    task.parameters.put("right", (String) participant.get("right"));
                }
                GregorianCalendar calendar = (GregorianCalendar) participant.get("dueDate");
                if (calendar != null) {
                    task.setDueDate(calendar.getTime());
                }
                mls.add(task);
            }
        }

        return mls;

    } catch (ClientException e) {
        throw new ClientRuntimeException(e);
    }
}

From source file:org.opcfoundation.ua.stacktest.io.DateConverter.java

@Override
public Object stringToObject(String str, Class type, Context context) {
    if (type == java.util.Date.class)
        try {//from   w  w  w .  ja  v  a2  s .  c  om
            return (java.util.Date) formatter.parse(str);
        } catch (ParseException e) {
            GregorianCalendar g = new GregorianCalendar();
            try {
                g = (GregorianCalendar) stringToObject(str, GregorianCalendar.class, context);
                return g.getTime();
            } catch (Exception ee) {
                ee.printStackTrace();
            }
        }
    else if (type == TestEvent.TestEventType.class) {
        if (str == "Started")
            return TestEvent.TestEventType.Started;
        if (str == "Completed")
            return TestEvent.TestEventType.Completed;
        if (str == "NotValidated")
            return TestEvent.TestEventType.NotValidated;
        if (str == "Failed")
            return TestEvent.TestEventType.Failed;
        if (str == "StackEvents")
            return TestEvent.TestEventType.StackEvents;
    }

    return super.stringToObject(str, type, context);
}

From source file:org.talend.designer.core.generic.model.migration.Salesforce620Migration.java

@Override
public Date getOrder() {
    GregorianCalendar gc = new GregorianCalendar(2016, 05, 25, 12, 0, 0);
    return gc.getTime();
}