List of usage examples for java.util GregorianCalendar setTimeZone
@Override public void setTimeZone(TimeZone zone)
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *//*from w w w .java2s .c o m*/ public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.HourTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. */// w w w . j av a2 s .com @Test public void testGetFirstMillisecondWithCalendar() { Hour h = new Hour(2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955764000000L, h.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.HourTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *///from www. ja v a 2s . c om @Test public void testGetLastMillisecondWithCalendar() { Hour h = new Hour(21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987890399999L, h.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:test.integ.be.fedict.hsm.ws.WSSecurityTestSOAPHandler.java
private Element addTimestamp(Element wsSecurityHeaderElement) throws SOAPException, DatatypeConfigurationException { if (false == this.addTimestamp) { return null; }//w w w . j a v a 2 s . c o m Document document = wsSecurityHeaderElement.getOwnerDocument(); Element timestampElement = document.createElementNS(WSU_NAMESPACE, "wsu:Timestamp"); timestampElement.setAttributeNS(WSU_NAMESPACE, "wsu:Id", "TS"); Attr idAttr = timestampElement.getAttributeNodeNS(WSU_NAMESPACE, "Id"); timestampElement.setIdAttributeNode(idAttr, true); Element createdElement = document.createElementNS(WSU_NAMESPACE, "wsu:Created"); DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); Date now = new Date(); gregorianCalendar.setTime(now); gregorianCalendar.setTimeZone(TimeZone.getTimeZone("UTC")); XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); createdElement.setTextContent(xmlGregorianCalendar.toXMLFormat()); timestampElement.appendChild(createdElement); Element expiresElement = document.createElementNS(WSU_NAMESPACE, "wsu:Expires"); Date expiresDate = new Date(now.getTime() + 1000 * 60 * 5); gregorianCalendar.setTime(expiresDate); xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); expiresElement.setTextContent(xmlGregorianCalendar.toXMLFormat()); timestampElement.appendChild(expiresElement); wsSecurityHeaderElement.appendChild(timestampElement); return timestampElement; }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.GmdConverter.java
/** * Builds up the xml paths and values to write. * Order matters! Paths should be added in the order they must be written. * * @param metacard// w ww . jav a2 s.c om * @return XstreamPathValueTracker containing XML paths and values to write */ protected XstreamPathValueTracker buildPaths(MetacardImpl metacard) { XstreamPathValueTracker pathValueTracker = new XstreamPathValueTracker(); pathValueTracker.add(new Path("/MD_Metadata/@xmlns"), GmdMetacardType.GMD_NAMESPACE); pathValueTracker.add(new Path("/MD_Metadata/@xmlns:" + GmdMetacardType.GCO_PREFIX), GmdMetacardType.GCO_NAMESPACE); pathValueTracker.add(new Path(GmdMetacardType.FILE_IDENTIFIER_PATH), metacard.getId()); pathValueTracker.add(new Path(GmdMetacardType.CODE_LIST_VALUE_PATH), StringUtils.defaultIfEmpty(metacard.getContentTypeName(), "dataset")); pathValueTracker.add(new Path(GmdMetacardType.CODE_LIST_PATH), GmdMetacardType.METACARD_URI); pathValueTracker.add(new Path(GmdMetacardType.CONTACT_PATH), (String) null); GregorianCalendar modifiedCal = new GregorianCalendar(); if (metacard.getModifiedDate() != null) { modifiedCal.setTime(metacard.getModifiedDate()); } modifiedCal.setTimeZone(UTC_TIME_ZONE); pathValueTracker.add(new Path(GmdMetacardType.DATE_TIME_STAMP_PATH), XSD_FACTORY.newXMLGregorianCalendar(modifiedCal).toXMLFormat()); addIdentificationInfo(metacard, pathValueTracker); addDistributionInfo(metacard, pathValueTracker); return pathValueTracker; }
From source file:org.jfree.data.time.junit.MillisecondTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *//*from ww w . j av a 2 s . com*/ public void testGetFirstMillisecondWithCalendar() { Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455500L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.junit.MillisecondTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *//*ww w . j a v a 2s . c om*/ public void testGetLastMillisecondWithCalendar() { Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550250L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.DayTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *///w w w.jav a2s. c om @Test public void testGetFirstMillisecondWithCalendar() { Day d = new Day(1, 12, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1007164800000L, d.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.junit.HourTest.java
/** * Some checks for the getFirstMillisecond(TimeZone) method. *///from ww w . j av a 2s . co m public void testGetFirstMillisecondWithCalendar() { Hour h = new Hour(2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955764000000L, h.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.time.junit.HourTest.java
/** * Some checks for the getLastMillisecond(TimeZone) method. *//*from w w w .j av a 2 s .c om*/ public void testGetLastMillisecondWithCalendar() { Hour h = new Hour(21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987890399999L, h.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }