Example usage for java.util Calendar JANUARY

List of usage examples for java.util Calendar JANUARY

Introduction

In this page you can find the example usage for java.util Calendar JANUARY.

Prototype

int JANUARY

To view the source code for java.util Calendar JANUARY.

Click Source Link

Document

Value of the #MONTH field indicating the first month of the year in the Gregorian and Julian calendars.

Usage

From source file:org.openmrs.module.sdmxhdintegration.reporting.extension.SDMXHDCrossSectionalReportRenderer.java

/**
  * @see org.openmrs.module.report.renderer.ReportRenderer#render(org.openmrs.module.report.ReportData, java.lang.String, java.io.OutputStream)
  *///  w  w w . j a  v  a2 s.co  m
@Override
public void render(ReportData reportData, String argument, OutputStream out)
        throws IOException, RenderingException {
    if (reportData.getDataSets().size() > 1) {
        throw new RenderingException(
                "This report contains multiple DataSets, this renderer does not support multiple DataSets");
    } else if (reportData.getDataSets().size() < 1) {
        throw new RenderingException("No DataSet defined in this report");
    }

    // get results dataSet
    org.openmrs.module.reporting.dataset.DataSet dataSet = reportData.getDataSets()
            .get(reportData.getDataSets().keySet().iterator().next());

    // get OMRS DSD
    Mapped<? extends DataSetDefinition> mappedOMRSDSD = reportData.getDefinition().getDataSetDefinitions()
            .get(reportData.getDefinition().getDataSetDefinitions().keySet().iterator().next());
    SDMXHDCohortIndicatorDataSetDefinition omrsDSD = (SDMXHDCohortIndicatorDataSetDefinition) mappedOMRSDSD
            .getParameterizable();

    // get SDMX-HD DSD
    SDMXHDService sdmxhdService = (SDMXHDService) Context.getService(SDMXHDService.class);
    SDMXHDMessage sdmxhdMessage = sdmxhdService.getMessage(omrsDSD.getSDMXHDMessageId());

    // get keyFamilyId
    KeyFamilyMapping keyFamilyMapping = sdmxhdService
            .getKeyFamilyMappingByReportDefinitionId(reportData.getDefinition().getId());
    String keyFamilyId = keyFamilyMapping.getKeyFamilyId();

    // get reporting month
    Date reportStartDate = (Date) reportData.getContext().getParameterValue("startDate");
    Date reportEndDate = (Date) reportData.getContext().getParameterValue("endDate");
    String timePeriod = null;

    // calculate time period and make sure reporting dates make sense
    String freq = sdmxhdMessage.getGroupElementAttributes().get("FREQ");
    if (freq != null) {
        if (freq.equals("M")) {
            // check that start and end date are the report are beginning and end day of the same month
            Calendar startCal = Calendar.getInstance();
            startCal.setTime(reportStartDate);

            int lastDay = startCal.getActualMaximum(Calendar.DAY_OF_MONTH);
            int month = startCal.get(Calendar.MONTH);
            int year = startCal.get(Calendar.YEAR);

            Calendar endCal = Calendar.getInstance();
            endCal.setTime(reportEndDate);

            if (endCal.get(Calendar.MONTH) != month || endCal.get(Calendar.DAY_OF_MONTH) != lastDay
                    || endCal.get(Calendar.YEAR) != year) {
                throw new RenderingException(
                        "Frequency is set to monthly, but the reporting stat and end date don't correspond to a start and end date of a specific month");
            }

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            timePeriod = sdf.format(reportStartDate);

        } else if (freq.equals("A")) {
            // check start and end date are beginning and end day of same year
            Calendar startCal = Calendar.getInstance();
            startCal.setTime(reportStartDate);

            int startDay = startCal.get(Calendar.DAY_OF_MONTH);
            int startMonth = startCal.get(Calendar.MONTH);
            int startYear = startCal.get(Calendar.YEAR);

            Calendar endCal = Calendar.getInstance();
            endCal.setTime(reportEndDate);

            int endDay = startCal.get(Calendar.DAY_OF_MONTH);
            int endMonth = startCal.get(Calendar.MONTH);
            int endYear = startCal.get(Calendar.YEAR);

            if (startDay != 1 || startMonth != Calendar.JANUARY || startYear != endYear || endDay != 31
                    || endMonth != Calendar.DECEMBER) {
                throw new RenderingException(
                        "Frequency is set to annual, but the reporting start and end date are not the begining of the end day of the same year");
            }

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            timePeriod = sdf.format(reportStartDate);
        }
        // TODO other checks
    }

    try {
        String path = Context.getAdministrationService()
                .getGlobalProperty("sdmxhdintegration.messageUploadDir");
        ZipFile zf = new ZipFile(path + File.separator + sdmxhdMessage.getZipFilename());
        SDMXHDParser parser = new SDMXHDParser();
        org.jembi.sdmxhd.SDMXHDMessage sdmxhdData = parser.parse(zf);
        DSD sdmxhdDSD = sdmxhdData.getDsd();

        //Construct CDS object
        Sender p = new Sender();
        p.setId("OMRS");
        p.setName("OpenMRS");

        Header h = new Header();
        h.setId("SDMX-HD-CSDS");
        h.setTest(false);
        h.setTruncated(false);
        h.getName().addValue("en", "OpenMRS SDMX-HD Export");
        h.setPrepared(iso8601DateFormat.format(new Date()));
        h.getSenders().add(p);

        h.setReportingBegin(iso8601DateFormat.format(reportStartDate));
        h.setReportingEnd(iso8601DateFormat.format(reportEndDate));

        // Construct dataset
        DataSet sdmxhdDataSet = new DataSet();

        sdmxhdDataSet.setReportingBeginDate(iso8601DateFormat.format(reportStartDate));
        sdmxhdDataSet.setReportingEndDate(iso8601DateFormat.format(reportEndDate));

        // Add fixed dataset attributes
        Map<String, String> datasetElementAttributes = sdmxhdMessage.getDatasetElementAttributes();
        for (String attribute : datasetElementAttributes.keySet()) {
            String value = datasetElementAttributes.get(attribute);
            if (StringUtils.hasText(value)) {
                sdmxhdDataSet.addAttribute(attribute, value);
            }
        }

        // Construct group
        Group group = new Group();

        // Set time period and frequency
        if (timePeriod != null)
            group.addAttribute("TIME_PERIOD", timePeriod);
        if (timePeriod != null)
            group.addAttribute("FREQ", freq);

        // Set DataSet attributes
        Map<String, String> dataSetAttachedAttributes = omrsDSD.getDataSetAttachedAttributes();
        for (String key : dataSetAttachedAttributes.keySet()) {
            sdmxhdDataSet.getAttributes().put(key, dataSetAttachedAttributes.get(key));
        }

        // Holder for all sections. Will hold a default section if no explicit hierarchy is found in SL_ISET
        List<Section> sectionList = new ArrayList<Section>();

        // Iterate each row and colum of the dataset
        for (DataSetRow row : dataSet) {
            for (DataSetColumn column : row.getColumnValues().keySet()) {

                CohortIndicatorAndDimensionColumn cidColumn = (CohortIndicatorAndDimensionColumn) column;
                Object value = row.getColumnValues().get(column);
                String columnName = column.getName();

                //get the indicator code for this column
                CohortIndicator indicator = cidColumn.getIndicator().getParameterizable();
                String sdmxhdIndicatorName = omrsDSD.getSDMXHDMappedIndicator(indicator.getId());

                // get indicator/dataelement codelist
                Dimension indDim = sdmxhdDSD.getIndicatorOrDataElementDimension(keyFamilyId);
                CodeList indCodeList = sdmxhdDSD.getCodeList(indDim.getCodelistRef());
                Code indCode = indCodeList.getCodeByDescription(sdmxhdIndicatorName);

                //setup or get the section for this indicator
                Section section = getSectionHelper(indCode, sectionList, sdmxhdDSD); //indicator code, listOfSections, message

                //get the dimension for the list of indicators (CL_INDICATOR)
                Dimension indDimension = sdmxhdDSD.getDimension(indCodeList);

                //construct new (SDMX-HD) obs to contain the indicator value
                Obs obs = new Obs();

                // set the indicator attribute
                obs.getAttributes().put(indDimension.getConceptRef(), indCode.getValue());

                // set Section Attributes
                Map<String, String> seriesAttachedAttributes = omrsDSD.getSeriesAttachedAttributes()
                        .get(columnName);
                if (seriesAttachedAttributes != null) {
                    for (String key : seriesAttachedAttributes.keySet()) {
                        section.getAttributes().put(key, seriesAttachedAttributes.get(key));
                    }
                }

                // write dimensions to obs
                Map<String, String> dimensionOptions = cidColumn.getDimensionOptions();
                // for each dimension option for this column
                for (String omrsDimensionId : dimensionOptions.keySet()) {
                    Integer omrsDimensionIdInt = Integer.parseInt(omrsDimensionId);
                    // find sdmx-hd dimension name in mapping
                    String sdmxhdDimensionName = null;
                    Map<String, Integer> omrsMappedDimensions = omrsDSD.getOMRSMappedDimensions();
                    for (String sdmxhdDimensionNameTemp : omrsMappedDimensions.keySet()) {
                        if (omrsMappedDimensions.get(sdmxhdDimensionNameTemp).equals(omrsDimensionIdInt)) {
                            sdmxhdDimensionName = sdmxhdDimensionNameTemp;
                            break;
                        }
                    }
                    // find sdmx-hd dimension option name in mapping
                    String omrsDimensionOptionName = dimensionOptions.get(omrsDimensionId);
                    String sdmxhdDimensionOptionName = null;
                    Map<String, String> omrsMappedDimensionOptions = omrsDSD.getOMRSMappedDimensionOptions()
                            .get(sdmxhdDimensionName);
                    for (String sdmxhdDimensionOptionNameTemp : omrsMappedDimensionOptions.keySet()) {
                        if (omrsMappedDimensionOptions.get(sdmxhdDimensionOptionNameTemp)
                                .equals(omrsDimensionOptionName)) {
                            sdmxhdDimensionOptionName = sdmxhdDimensionOptionNameTemp;
                            break;
                        }
                    }
                    //find code corresponding to this dimension option
                    Dimension sdmxhdDimension = sdmxhdDSD.getDimension(sdmxhdDimensionName, keyFamilyId);
                    CodeList codeList = sdmxhdDSD.getCodeList(sdmxhdDimension.getCodelistRef());
                    Code code = codeList.getCodeByDescription(sdmxhdDimensionOptionName);
                    obs.addAttribute(sdmxhdDimensionName, code.getValue());
                }

                // add dimensions with default values
                List<String> mappedFixedDimensions = omrsDSD.getMappedFixedDimension(columnName);
                Map<String, String> fixedDimensionValues = omrsDSD.getFixedDimensionValues();
                for (String sdmxhdDimension : mappedFixedDimensions) {
                    if (fixedDimensionValues.get(sdmxhdDimension) != null) {
                        String fixedValue = fixedDimensionValues.get(sdmxhdDimension);
                        Dimension dimension = sdmxhdDSD.getDimension(sdmxhdDimension, keyFamilyId);
                        CodeList codeList = sdmxhdDSD.getCodeList(dimension.getCodelistRef());
                        Code code = codeList.getCodeByDescription(fixedValue);
                        obs.addAttribute(sdmxhdDimension, code.getValue());
                    }
                }

                // set Obs Attributes
                Map<String, String> obsAttachedAttributes = omrsDSD.getObsAttachedAttributes().get(columnName);
                if (obsAttachedAttributes != null) {
                    for (String key : obsAttachedAttributes.keySet()) {
                        obs.getAttributes().put(key, obsAttachedAttributes.get(key));
                    }
                }

                String primaryMeasure = sdmxhdDSD.getKeyFamily(keyFamilyId).getComponents().getPrimaryMeasure()
                        .getConceptRef();
                obs.elementName = primaryMeasure;

                // write value
                if (value instanceof CohortIndicatorAndDimensionResult) {
                    CohortIndicatorAndDimensionResult typedValue = (CohortIndicatorAndDimensionResult) value;
                    obs.getAttributes().put("value", typedValue.getValue().toString());
                } else {
                    obs.getAttributes().put("value", value.toString());
                }

                section.getObs().add(obs);
            }
        }

        // Add all sections to group
        for (Section section : sectionList) {
            group.getSections().add(section);
        }

        // Add group to dataset
        sdmxhdDataSet.getGroups().add(group);

        CSDS csds = new CSDS();
        csds.getDatasets().add(sdmxhdDataSet);
        csds.setHeader(h);

        // build up namespace
        KeyFamily keyFamily = sdmxhdDSD.getKeyFamily(keyFamilyId);
        String derivedNamespace = Constants.DERIVED_NAMESPACE_PREFIX + keyFamily.getAgencyID() + ":"
                + keyFamily.getId() + ":" + keyFamily.getVersion() + ":cross";
        String xml = csds.toXML(derivedNamespace);

        // output csds in original zip
        zf = new ZipFile(path + File.separator + sdmxhdMessage.getZipFilename());
        Utils.outputCsdsInDsdZip(zf, xml, out);
    } catch (IllegalArgumentException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    } catch (XMLStreamException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    } catch (ExternalRefrenceNotFoundException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    } catch (ValidationException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    } catch (SchemaValidationException e) {
        log.error("Error generated", e);
        throw new RenderingException("Error rendering the SDMX-HD message: " + e.getMessage(), e);
    }
}

From source file:com.baidu.rigel.biplatform.tesseract.meta.impl.TimeDimensionMemberServiceImpl.java

/**
 * ??// w w  w .  j av a2 s . c  om
 * 
 * @param year
 * @return
 */
private List<MiniCubeMember> genDayMembersWithWeekParentForAll(Level level, Member parentMember)
        throws Exception {
    List<MiniCubeMember> members = Lists.newArrayList();
    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int weekNow = cal.get(Calendar.WEEK_OF_YEAR);
    cal.set(Calendar.MONTH, Calendar.JANUARY);
    cal.set(Calendar.DATE, 1);
    Date firstWeek = getFirstDayOfWeek(cal.getTime());
    cal.setTime(firstWeek);
    int week = 1;
    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
    while (week <= weekNow) {
        String day = sf.format(cal.getTime());
        MiniCubeMember dayMember = new MiniCubeMember(day);
        String caption = year + "" + week + "-" + day;
        dayMember.setCaption(caption);
        dayMember.setLevel(level);
        dayMember.setParent(parentMember);
        dayMember.setName(day);
        dayMember.setVisible(true);
        for (int i = 0; i <= 6; i++) {
            day = sf.format(cal.getTime());
            dayMember.getQueryNodes().add(day);
            cal.add(Calendar.DATE, 1);
        }
        members.add(dayMember);
        // cal.add(Calendar.DATE, 1);
        week++;
    }
    return members;
}

From source file:ips1ap101.lib.base.util.TimeUtils.java

public static Time newTime(java.util.Date date) {
    if (date == null) {
        return null;
    } else {/*from   w ww . j  ava  2 s  . co m*/
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(date.getTime());
        c.set(Calendar.YEAR, 1970);
        c.set(Calendar.MONTH, Calendar.JANUARY);
        c.set(Calendar.DAY_OF_MONTH, 1);
        return new Time(c.getTimeInMillis());
    }
}

From source file:org.pentaho.metaverse.api.MetaverseLogicalIdGeneratorTest.java

@Test
public void testGenerateLogicalId_notAllRequiredPropertiesAvailable() throws Exception {
    when(node.getProperty("name")).thenReturn("john doe");
    when(node.getProperty("age")).thenReturn(30);

    // don't set the address property on the node

    Calendar cal = GregorianCalendar.getInstance();
    cal.set(1976, Calendar.JANUARY, 1, 0, 0, 0);
    when(node.getProperty("birthday")).thenReturn(cal.getTime());

    when(node.getPropertyKeys()).thenReturn(new HashSet<String>() {
        {/*from w  w  w. j  ava 2 s.c o m*/
            //      add( "address" );
            add("age");
            add("birthday");
            add("name");
        }
    });

    // make sure there is no logicalid on the node initially
    assertNull(node.getProperty(DictionaryConst.PROPERTY_LOGICAL_ID));

    String logicalId = idGenerator.generateId(node);

    // it should come out in alphabetical order by key
    // it should also include address in the id but have no value for it since it wasn't set on the node
    assertEquals("{\"address\":\"\",\"age\":\"30\",\"birthday\":\"1976-01-01 00:00:00\",\"name\":\"john doe\"}",
            logicalId);

    // make sure a call was made to add the logical id as a property
    verify(node).setProperty(DictionaryConst.PROPERTY_LOGICAL_ID, logicalId);
}

From source file:net.sourceforge.openutils.mgnlcriteria.jcr.query.lucene.AclSearchIndexTest.java

/**
 * Tests that the execution of a query on all pets does not return any dog, because of an ACL rule.
 * @throws Exception//from  w w  w . j  ava  2s.c  o  m
 */
@Test
public void testDogsExcluded() throws Exception {
    final AccessManager wrappedAM = MgnlContext.getAccessManager(RepositoryConstants.WEBSITE);

    Assert.assertNotNull(wrappedAM, "AccessManager is null");

    final AccessManager wrapperAM = new AccessManager() {

        public boolean isGranted(String path, long permissions) {
            // ACL rule: read permission on pets subtree
            if (StringUtils.startsWith(path, "/pets/")) {
                // ACL rule: deny permission on dogs subtree
                return !StringUtils.startsWith(path, "/pets/dogs/");
            }
            return wrappedAM.isGranted(path, permissions);
        }

        public void setPermissionList(List<Permission> permissions) {
            wrappedAM.setPermissionList(permissions);
        }

        public List<Permission> getPermissionList() {
            return wrappedAM.getPermissionList();
        }

        public long getPermissions(String path) {
            return wrappedAM.getPermissions(path);
        }
    };
    MgnlContext.setInstance(new ContextDecorator(MgnlContext.getInstance()) {

        /**
         * {@inheritDoc}
         */
        @Override
        public AccessManager getAccessManager(String name) {
            if (RepositoryConstants.WEBSITE.equals(name)) {
                return wrapperAM;
            }
            return super.getAccessManager(name);
        }
    });
    try {
        Calendar begin = Calendar.getInstance();
        begin.set(1999, Calendar.JANUARY, 1);
        Calendar end = Calendar.getInstance();
        end.set(2001, Calendar.DECEMBER, 31);

        Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(RepositoryConstants.WEBSITE)
                .setBasePath("/pets").add(Restrictions.between("@birthDate", begin, end))
                .addOrder(Order.asc("@birthDate"));

        AdvancedResult result = criteria.execute();

        // Accessible results (dogs excluded):
        // --- 9 (title=Lucky, petType=bird, birthDate=1999-08-06)
        // --- 6 (title=George, petType=snake, birthDate=2000-01-20)
        // --- 11 (title=Freddy, petType=bird, birthDate=2000-03-09)
        // --- 1 (title=Leo, petType=cat, birthDate=2000-09-07)
        // --- 5 (title=Iggy, petType=lizard, birthDate=2000-11-30)
        ResultIterator<? extends Node> iterator = result.getItems();

        Assert.assertTrue(iterator.hasNext());
        Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "9");
        Assert.assertTrue(iterator.hasNext());
        Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "6");
        Assert.assertTrue(iterator.hasNext());
        Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "11");
        Assert.assertTrue(iterator.hasNext());
        Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "1");
        Assert.assertTrue(iterator.hasNext());
        Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "5");
        Assert.assertFalse(iterator.hasNext());
    } finally {
        MgnlContext.setInstance(((ContextDecorator) MgnlContext.getInstance()).getWrappedContext());
    }
}

From source file:agency.AgentManagerImplTest.java

@Test
public void testUpdateAgentValidNote() {
    //create agents
    Agent agent = newAgent01();/*from w  w w  . j a  va2 s. c  o m*/
    Agent agent02 = newAgent02();

    manager.createAgent(agent);
    manager.createAgent(agent02);

    Agent reference = manager.findAgentById(agent.getId());
    assertNotNull("Agent has not been added to the DB", reference);
    reference.setNote("Not a good agent after all");

    manager.updateAgent(reference);
    assertEquals("Error update of agent note", "Not a good agent after all", reference.getNote());
    assertEquals("Error in name attribute while updating agent's note", "James Bond", reference.getName());
    assertEquals("Error in born attribute while updating agent's note",
            new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime(), reference.getBorn());
    assertEquals("Error in level attribute while updating agent's note", 5, reference.getLevel());

    //test null note
    reference.setNote(null);

    manager.updateAgent(reference);
    assertEquals("Error update of agent note", null, reference.getNote());
    assertEquals("Error in name attribute while updating agent's note", "James Bond", reference.getName());
    assertEquals("Error in born attribute while updating agent's note",
            new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime(), reference.getBorn());
    assertEquals("Error in level attribute while updating agent's note", 5, reference.getLevel());

    // Check if updates didn't affect other records
    assertDeepEquals(agent02, manager.findAgentById(agent02.getId()));
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java

private String monthToString(int month, Locale locale) {
    switch (month) {

    case Calendar.JANUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Janeiro";
        }/*w  ww. ja  va 2  s .  c om*/
        return "January";
    case Calendar.FEBRUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Fevereiro";
        }
        return "February";
    case Calendar.MARCH:
        if (locale.getLanguage().equals("pt")) {
            return "Maro";
        }
        return "March";
    case Calendar.APRIL:
        if (locale.getLanguage().equals("pt")) {
            return "Abril";
        }
        return "April";
    case Calendar.MAY:
        if (locale.getLanguage().equals("pt")) {
            return "Maio";
        }
        return "May";
    case Calendar.JUNE:
        if (locale.getLanguage().equals("pt")) {
            return "Junho";
        }
        return "June";
    case Calendar.JULY:
        if (locale.getLanguage().equals("pt")) {
            return "Julho";
        }
        return "July";
    case Calendar.AUGUST:
        if (locale.getLanguage().equals("pt")) {
            return "Agosto";
        }
        return "August";
    case Calendar.SEPTEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Setembro";
        }
        return "September";
    case Calendar.OCTOBER:
        if (locale.getLanguage().equals("pt")) {
            return "Outubro";
        }
        return "October";
    case Calendar.NOVEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Novembro";
        }
        return "November";
    case Calendar.DECEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Dezembro";
        }
        return "December";
    case Calendar.UNDECIMBER:
        return "Undecember";
    default:
        return "Error";
    }
}

From source file:org.jfree.data.time.WeekTest.java

/**
 * A test case for bug 1498805.//from  ww  w  . java  2 s  .  com
 */
@Test
public void testBug1498805() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.UK);
    try {
        TimeZone zone = TimeZone.getTimeZone("GMT");
        GregorianCalendar gc = new GregorianCalendar(zone);
        gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0);
        Week w = new Week(gc.getTime(), zone);
        assertEquals(53, w.getWeek());
        assertEquals(new Year(2004), w.getYear());
    } finally {
        Locale.setDefault(saved);
    }
}

From source file:org.jfree.data.time.MinuteTest.java

/**
 * Some checks for the getStart() method.
 *//*from w ww. jav  a  2 s. c om*/
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    TimeZone savedZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome"));
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Minute m = new Minute(47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);
    TimeZone.setDefault(savedZone);
}

From source file:org.jfree.data.time.SecondTest.java

/**
 * Some checks for the getStart() method.
 *//*from w ww  .jav a 2 s .c  o  m*/
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55);
    cal.set(Calendar.MILLISECOND, 0);
    Second s = new Second(55, 47, 3, 16, 1, 2006);
    assertEquals(cal.getTime(), s.getStart());
    Locale.setDefault(saved);
}