List of usage examples for java.util GregorianCalendar set
public final void set(int year, int month, int date)
YEAR
, MONTH
, and DAY_OF_MONTH
. From source file:org.opens.tgol.controller.PageListControllerTest.java
/** * /*from w w w .j av a 2s.c o m*/ * @param isActSiteScope */ private void setUpActDataService(boolean isActSiteScope) { mockGroupOfPagesScope = createMock(Scope.class); mockSiteScope = createMock(Scope.class); mockContract = createMock(Contract.class); Collection<Contract> contractSet = new HashSet<Contract>(); contractSet.add(mockContract); mockActDataService = createMock(ActDataService.class); mockAct = createMock(Act.class); expect(mockActDataService.getActFromAudit(mockAudit)).andReturn(mockAct).anyTimes(); expect(mockAct.getContract()).andReturn(mockContract).anyTimes(); if (isActSiteScope) { expect(mockSiteScope.getCode()).andReturn(ScopeEnum.DOMAIN).anyTimes(); expect(mockAct.getScope()).andReturn(mockSiteScope).anyTimes(); } else { expect(mockGroupOfPagesScope.getCode()).andReturn(ScopeEnum.GROUPOFPAGES).anyTimes(); expect(mockAct.getScope()).andReturn(mockGroupOfPagesScope).anyTimes(); } GregorianCalendar calendar = new GregorianCalendar(); calendar.set(2030, 01, 01); expect(mockContract.getEndDate()).andReturn(calendar.getTime()).anyTimes(); expect(mockContract.getUser()).andReturn(mockUser).anyTimes(); expect(mockContract.getLabel()).andReturn("CONTRACT LABEL").anyTimes(); expect(mockContract.getId()).andReturn(Long.valueOf(1)).anyTimes(); replay(mockActDataService); replay(mockAct); replay(mockContract); replay(mockSiteScope); replay(mockGroupOfPagesScope); instance.setActDataService(mockActDataService); AuditStatisticsFactory.getInstance().setActDataService(mockActDataService); }
From source file:org.asqatasun.webapp.controller.PageListControllerTest.java
/** * //from w ww. jav a2 s .c o m * @param isActSiteScope */ private void setUpActDataService(boolean isActSiteScope) { mockGroupOfPagesScope = createMock(Scope.class); mockSiteScope = createMock(Scope.class); mockContract = createMock(Contract.class); mockActDataService = createMock(ActDataService.class); mockAct = createMock(Act.class); expect(mockActDataService.getActFromAudit(mockAudit)).andReturn(mockAct).anyTimes(); expect(mockAct.getContract()).andReturn(mockContract).anyTimes(); if (isActSiteScope) { expect(mockSiteScope.getCode()).andReturn(ScopeEnum.DOMAIN).anyTimes(); expect(mockAct.getScope()).andReturn(mockSiteScope).anyTimes(); } else { expect(mockGroupOfPagesScope.getCode()).andReturn(ScopeEnum.GROUPOFPAGES).anyTimes(); expect(mockAct.getScope()).andReturn(mockGroupOfPagesScope).anyTimes(); } GregorianCalendar calendar = new GregorianCalendar(); calendar.set(2030, 01, 01); expect(mockContract.getEndDate()).andReturn(calendar.getTime()).anyTimes(); expect(mockContract.getUser()).andReturn(mockUser).anyTimes(); expect(mockContract.getLabel()).andReturn("CONTRACT LABEL").anyTimes(); expect(mockContract.getId()).andReturn(Long.valueOf(1)).anyTimes(); replay(mockActDataService); replay(mockAct); replay(mockContract); replay(mockSiteScope); replay(mockGroupOfPagesScope); instance.setActDataService(mockActDataService); AuditStatisticsFactory.getInstance().setActDataService(mockActDataService); }
From source file:ca.uhn.hl7v2.model.primitive.CommonTSTest.java
/** * See bug 3545328/*ww w .j av a 2 s . c o m*/ * * This bug has not yet been evaluated, so the test will fail. */ @Test public void testOffsetProblem() throws HL7Exception { GregorianCalendar hapiTestCalendar = (GregorianCalendar) GregorianCalendar .getInstance(TimeZone.getTimeZone("CET")); hapiTestCalendar.set(2012, Calendar.FEBRUARY, 1); hapiTestCalendar = (GregorianCalendar) DateUtils.truncate(hapiTestCalendar, Calendar.DATE); assertEquals("20120201000000+0100", CommonTS.toHl7TSFormat(hapiTestCalendar)); hapiTestCalendar.set(2012, Calendar.AUGUST, 1); assertEquals("20120801000000+0200", CommonTS.toHl7TSFormat(hapiTestCalendar)); }
From source file:com.sapienter.jbilling.common.GatewayBL.java
private CreditCardDTO parseCreditCard() throws ValidatorException { CreditCardDTO creditCard = new CreditCardDTO(); creditCard.setNumber(getStringPar("s_number")); creditCard.setName(getStringPar("s_name")); validate("CreditCard", creditCard); // get the expiry date Integer month = getIntPar("s_expiry_month", true); Integer year = getIntPar("s_expiry_year", true); vRange("s_expiry_month", 1, 12); vRange("s_expiry_year", 4, 99); if (code != RES_CODE_OK) { return null; }/*ww w. j av a2s. co m*/ GregorianCalendar cal = new GregorianCalendar(); cal.clear(); cal.set(year.intValue() + 2000, month.intValue() - 1, 1); creditCard.setCcExpiry(cal.getTime()); return creditCard; }
From source file:org.oscarehr.common.model.Demographic.java
public GregorianCalendar getBirthDay() { GregorianCalendar cal = null; if (dateOfBirth != null && monthOfBirth != null && yearOfBirth != null) { cal = new GregorianCalendar(); cal.setTimeInMillis(0);//from w w w . ja v a 2 s. c o m cal.set(Integer.parseInt(yearOfBirth), Integer.parseInt(monthOfBirth) - 1, Integer.parseInt(dateOfBirth)); // force materialisation of data cal.getTimeInMillis(); } return (cal); }
From source file:v800_trainer.JCicloTronic.java
private void Datenliste_ZeitabschnittActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Datenliste_ZeitabschnittActionPerformed // Add your handling code here: if (Update == false) { return;//from ww w.ja v a 2s . c o m } int Tag, Monat, Jahr; int i, Zeitdifferenz = 0; String dummy; java.util.GregorianCalendar Kalendera; java.util.GregorianCalendar Kalenderb; SelectionChanged = true; Update = false; Datenliste_Monat.setEnabled(false); if (Datenliste_Monat.getItemCount() != 0) Datenliste_Monat.setSelectedIndex(0); if (Datenliste_Jahr.getItemCount() != 0) Datenliste_Jahr.setSelectedIndex(0); Update = true; Datentabelle.clearSelection(); if (Datenliste_Zeitabschnitt.getSelectedIndex() == 0) { // jTable1.addRowSelectionInterval(0,0); return; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 1) { Zeitdifferenz = 8; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 2) { Zeitdifferenz = 31; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 3) { Zeitdifferenz = 366; } if (Datenliste_Zeitabschnitt.getSelectedIndex() == 4) { Zeitdifferenz = -1; } Kalendera = (java.util.GregorianCalendar) java.util.GregorianCalendar.getInstance(); Kalenderb = (java.util.GregorianCalendar) java.util.GregorianCalendar.getInstance(); if (Zeitdifferenz != -1) { Kalendera.add(Calendar.DATE, -Zeitdifferenz); } for (i = 0; i < Datentabelle.getRowCount(); i++) { dummy = (String) (Datentabelle.getValueAt(i, 0)); Jahr = Integer.parseInt(dummy.substring(8)); Monat = Integer.parseInt(dummy.substring(5, 7)); Tag = Integer.parseInt(dummy.substring(2, 4)); Kalenderb.set(Jahr, Monat - 1, Tag - 1); if ((Kalendera.before(Kalenderb) || Zeitdifferenz == -1) & (Datenliste_TourTyp.getSelectedItem().toString().equals(sorter.getValueAt(i, 6).toString()) || Datenliste_TourTyp.getSelectedIndex() == 0)) { Datentabelle.addRowSelectionInterval(i, i); } jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount()); } }