List of usage examples for java.util SimpleTimeZone SimpleTimeZone
public SimpleTimeZone(int rawOffset, String ID)
From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java
public JFreeChart getTimeChart() { double[] graphTable = this.counter.graphDataset.getGraphArray(); double[] weightTable = null; if (this instanceof StatValue) { weightTable = ((StatValue) this).eventCounter.graphDataset.getGraphArray(); }//from w w w . j a va 2 s. c om TimeSeries timeSeries = new TimeSeries("", FixedMillisecond.class); double hits = 0; long offset; boolean absoluteDate = Config.getConfigByName("tester.properties").getBoolean("stats.CHARTS_ABSOLUTE_DATE", false); if (absoluteDate) { offset = reportZeroTimestamp; } else { offset = 0; } for (int i = 0; i < graphTable.length; i++) { long timestamp = offset + i * this.counter.graphDataset.graphParameters.graphPeriod; timeSeries.add(new FixedMillisecond(timestamp), graphTable[i], false); } JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title null, // domain axis label null, // range axis label new TimeSeriesCollection(timeSeries), // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false // urls ); if (null != mean && null != std_dv) { chart.getXYPlot().addRangeMarker(new ValueMarker(mean)); IntervalMarker intervalMarker = new IntervalMarker(mean - std_dv / 2, mean + std_dv / 2); intervalMarker.setAlpha(0.3f); chart.getXYPlot().addRangeMarker(intervalMarker); } chart.getXYPlot().setDomainAxis(new DateAxis()); DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis(); DateFormat dateFormat; if (absoluteDate) { dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss"); axis.setVerticalTickLabels(true); } else { dateFormat = new SimpleDateFormat("HH:mm:ss"); dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); } axis.setDateFormatOverride(dateFormat); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:edu.fullerton.viewerplugin.TsPlot.java
private TimeSeries LinFit(TimeSeries ts) { TimeSeries ret = new TimeSeries("lin fit", Millisecond.class); SimpleTimeZone utctz = new SimpleTimeZone(0, "UTC"); int n = ts.getItemCount(); double[] x = new double[n]; double[] y = new double[n]; TimeSeriesDataItem it;// ww w .java2 s. c om for (int i = 0; i < n; i++) { it = ts.getDataItem(i); x[i] = it.getPeriod().getFirstMillisecond() + 0.; y[i] = it.getValue().doubleValue(); } LinearRegression lr = new LinearRegression(x, y); double b = lr.getIntercept(); double m = lr.getSlope(); double fit, t; for (int i = 0; i < n; i++) { it = ts.getDataItem(i); t = it.getPeriod().getFirstMillisecond() + 0.; fit = m * t + b; ret.addOrUpdate(it.getPeriod(), fit); } return ret; }
From source file:cn.ctyun.amazonaws.auth.AWS4Signer.java
protected String getDateTimeStamp(Date date) { SimpleDateFormat dateTimeFormat; dateTimeFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'"); dateTimeFormat.setTimeZone(new SimpleTimeZone(0, "UTC")); return dateTimeFormat.format(date); }
From source file:cn.ctyun.amazonaws.auth.AWS4Signer.java
protected String getDateStamp(Date date) { SimpleDateFormat dateStampFormat; dateStampFormat = new SimpleDateFormat("yyyyMMdd"); dateStampFormat.setTimeZone(new SimpleTimeZone(0, "UTC")); return dateStampFormat.format(date); }
From source file:com.qut.middleware.esoe.sso.impl.AuthenticationAuthorityProcessorFuncTest.java
/** * Creates an Invalid SAML AuthnRequest. The genertaed request is invalid because SAML version is not 2.0. * // w w w. j a va2 s . c o m * @return String containing SAML AuthnRequest */ private byte[] generateInvalidRequest() throws Exception { AudienceRestriction audienceRestriction = new AudienceRestriction(); Conditions conditions = new Conditions(); NameIDType nameID = new NameIDType(); NameIDType issuer = new NameIDType(); NameIDPolicy policy = new NameIDPolicy(); Subject subject = new Subject(); Signature signature = new Signature(); AuthnRequest authnRequest = new AuthnRequest(); byte[] result; /* GMT timezone */ SimpleTimeZone gmt = new SimpleTimeZone(0, "GMT+10"); /* GregorianCalendar with the GMT time zone */ GregorianCalendar calendar = new GregorianCalendar(gmt); XMLGregorianCalendar xmlCalendar = new XMLGregorianCalendarImpl(calendar); audienceRestriction.getAudiences().add("spep-n1.qut.edu.au"); audienceRestriction.getAudiences().add("spep-n2.qut.edu.au"); conditions.getConditionsAndOneTimeUsesAndAudienceRestrictions().add(audienceRestriction); nameID.setValue("beddoes@qut.com"); nameID.setFormat("urn:oasis:names:tc:SAML:2.0:something"); subject.setNameID(nameID); issuer.setValue(this.issuer); policy.setAllowCreate(true); authnRequest.setNameIDPolicy(policy); authnRequest.setSignature(signature); authnRequest.setSubject(subject); authnRequest.setConditions(conditions); authnRequest.setForceAuthn(false); authnRequest.setIsPassive(false); authnRequest.setAssertionConsumerServiceIndex(0); authnRequest.setProviderName("spep-n1"); authnRequest.setID("abe567de6-122wert67"); /* Set invalid version to trip up validator */ authnRequest.setVersion("1.0"); authnRequest.setIssueInstant(xmlCalendar); authnRequest.setIssuer(issuer); result = marshaller.marshallSigned(authnRequest); return Base64.encodeBase64(result); }
From source file:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java
public static String generateYear() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);//from w w w.j a v a 2s . c om guid.append(calendar.get(Calendar.YEAR)); return guid.toString(); }
From source file:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java
public static String generateTimeString() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);/*w ww .ja v a2 s . co m*/ guid.append(calendar.get(Calendar.YEAR)); guid.append(calendar.get(Calendar.DAY_OF_YEAR)); guid.append(calendar.get(Calendar.HOUR_OF_DAY)); guid.append(calendar.get(Calendar.MINUTE)); guid.append(calendar.get(Calendar.SECOND)); guid.append(calendar.get(Calendar.MILLISECOND)); double random = Math.random(); guid.append(random); return guid.toString(); }
From source file:com.krawler.common.timezone.Timezone.java
public static String[] getGmtDate(Connection conn, String date1, String userid) throws ServiceException, ParseException { String tzUser = getTimeZone(conn, userid); Calendar calInstance = Calendar.getInstance(); calInstance.setTimeZone(java.util.TimeZone.getTimeZone("GMT" + tzUser)); TimeZone tz = calInstance.getTimeZone(); int temp = tz.getRawOffset(); java.text.SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-d HH:mm:ss"); java.text.SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-d HH:mm:ss"); java.util.Calendar cal0 = Calendar.getInstance(new SimpleTimeZone(0, "GMT")); java.util.Calendar cal1 = Calendar.getInstance(new SimpleTimeZone(temp, tzUser)); format0.setCalendar(cal0);/* w ww . j ava2 s . c o m*/ format1.setCalendar(cal1); String dateArr[] = date1.split(" "); if (dateArr.length == 1 || dateArr[1].equals("00:00:00")) { date1 = dateArr[0] + " " + "00:00:01"; } java.util.Date date = format1.parse(date1); String result = format0.format(date); String[] results = result.split(" "); return results; }
From source file:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java
private String generateId() { int version = 1; StringBuffer docid = new StringBuffer(DATAIDPREFIX); docid.append(DOT);/* w w w . jav a2s . co m*/ // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int time = 0; docid.append(calendar.get(Calendar.YEAR)); time = calendar.get(Calendar.DAY_OF_YEAR); if (time < 10) { docid.append("0"); docid.append("0"); docid.append(time); } else if (time < 100) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.HOUR_OF_DAY); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.MINUTE); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.SECOND); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } //sometimes this number is not unique, so we append a random number int random = (new Double(Math.random() * 100)).intValue(); docid.append(random); docid.append(DOT); docid.append(version); return docid.toString(); }
From source file:edu.fullerton.viewerplugin.TsPlot.java
private void addTimeSeries(ChanDataBuffer dbuf, boolean compact, TimeSeriesCollection mtds) throws LdvTableException { String legend = getLegend(dbuf, compact); TimeSeries ts;//from w ww .j a v a 2s .c o m ts = new TimeSeries(legend, Millisecond.class); SimpleTimeZone utctz = new SimpleTimeZone(0, "UTC"); float rate = dbuf.getChanInfo().getRate(); double msPerSample = 1000 / rate; long startMs = TimeAndDate.gps2utc(dbuf.getTimeInterval().getStartGps()) * 1000; float[] data = dbuf.getData(); for (int i = 0; i < dbuf.getDataLength(); i++) { long curMs = Math.round(msPerSample * i + startMs); Date t = new Date(curMs); ts.addOrUpdate(new Millisecond(t, utctz), data[i]); if (msPerSample >= 1000) { // this plots trend data as stair steps long endMs = Math.round(curMs + msPerSample - 1); Date t1 = new Date(endMs); ts.addOrUpdate(new Millisecond(t1, utctz), data[i]); } } mtds.addSeries(ts); if (addLinFit) { TimeSeries linTs = LinFit(ts); mtds.addSeries(linTs); } }