List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:org.jfree.chart.demo.PeriodAxisDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); }//from ww w . jav a2 s. co m PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); return jfreechart; }
From source file:com.nexmo.client.voice.CallsFilterTest.java
@Test public void testAllParams() { /*//from ww w. j a v a 2 s. c om private Integer recordIndex; private String order; */ Calendar startCalendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); startCalendar.set(2016, Calendar.JANUARY, 1, 7, 8, 20); startCalendar.set(Calendar.MILLISECOND, 0); Date startDate = startCalendar.getTime(); Calendar endCalendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); endCalendar.set(2016, Calendar.JANUARY, 1, 7, 8, 55); endCalendar.set(Calendar.MILLISECOND, 0); Date endDate = endCalendar.getTime(); CallsFilter filter = new CallsFilter(); filter.setStatus(CallStatus.COMPLETED); filter.setDateStart(startDate); filter.setDateEnd(endDate); filter.setRecordIndex(12); filter.setOrder("asc"); filter.setPageSize(10); filter.setConversationUuid("this-is-not-a-uuid"); assertEquals(CallStatus.COMPLETED, filter.getStatus()); assertEquals(startDate, filter.getDateStart()); assertEquals(endDate, filter.getDateEnd()); assertEquals(12, (int) filter.getRecordIndex()); assertEquals("asc", filter.getOrder()); assertEquals(10, (int) filter.getPageSize()); assertEquals("this-is-not-a-uuid", filter.getConversationUuid()); List<NameValuePair> params = filter.toUrlParams(); Map<String, String> paramLookup = new HashMap<String, String>(); for (NameValuePair pair : params) { paramLookup.put(pair.getName(), pair.getValue()); } assertEquals("completed", paramLookup.get("status")); assertEquals("2016-01-01T07:08:55Z", paramLookup.get("date_end")); assertEquals("2016-01-01T07:08:20Z", paramLookup.get("date_start")); assertEquals("12", paramLookup.get("record_index")); assertEquals("asc", paramLookup.get("order")); assertEquals("10", paramLookup.get("page_size")); assertEquals("this-is-not-a-uuid", paramLookup.get("conversation_uuid")); }
From source file:Main.java
private static GregorianCalendar gmtStringToGregorianCalendar(String stringTypeDate) throws DatatypeConfigurationException { String yyyy = stringTypeDate.substring(0, 4); String mm = stringTypeDate.substring(5, 7); String dd = stringTypeDate.substring(8, 10); String hh = "00"; String mi = "00"; String ss = "00"; String ms = "00"; String tz = null;/*from w w w . ja va2 s . c om*/ if (stringTypeDate.length() > 23) { hh = stringTypeDate.substring(11, 13); mi = stringTypeDate.substring(14, 16); ss = stringTypeDate.substring(17, 19); ms = stringTypeDate.substring(20, 23); tz = stringTypeDate.substring(23); } else { tz = stringTypeDate.substring(10); //tz = "+09:00"; } if (tz.equals("Z")) { tz = "UTC"; } else { tz = "GMT" + tz; } int iyyyy = Integer.parseInt(yyyy); int imm = Integer.parseInt(mm) - 1; int idd = Integer.parseInt(dd); int ihh = Integer.parseInt(hh); int imi = Integer.parseInt(mi); int iss = Integer.parseInt(ss); int ims = Integer.parseInt(ms); Calendar c = Calendar.getInstance(); c.setTimeZone(TimeZone.getTimeZone(tz)); c.set(iyyyy, imm, idd, ihh, imi, iss); c.set(Calendar.MILLISECOND, ims); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(c.getTime()); cal.setTimeZone(TimeZone.getTimeZone("ROK")); return cal; }
From source file:net.servicefixture.converter.CalendarConverter.java
public String toString(Object source) { SimpleDateFormat formatter = new SimpleDateFormat(DateConverter.DATE_FORMAT); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(((Calendar) source).getTime()); }
From source file:org.jfree.chart.demo.PeriodAxisDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); }//from www.ja v a 2 s .c om PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Month.class); periodaxis.setMajorTickTimePeriodClass(org.jfree.data.time.Month.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); return jfreechart; }
From source file:XSDDateTime.java
public static Calendar parse(String dt) { String[] dateTime = dt.split("T"); String date = dateTime[0];//from ww w . j av a 2 s . c o m String time = dateTime[1]; String[] ymd = date.split("-"); int year = Integer.parseInt(ymd[0]); int month = Integer.parseInt(ymd[1]) - 1; int day = Integer.parseInt(ymd[2]); String[] hms = time.split(":"); int hour = Integer.parseInt(hms[0]); int minutes = Integer.parseInt(hms[1]); int seconds = Integer.parseInt(hms[2].substring(0, 2)); TimeZone tz = TimeZone.getTimeZone("GMT+00:00"); Calendar cal = Calendar.getInstance(tz, Locale.US); cal.set(year, month, day, hour, minutes, seconds); return cal; }
From source file:de.taimos.gpsd4java.backend.AbstractResultParser.java
/** * Create new ResultParser//from w w w .ja v a 2 s .com */ public AbstractResultParser() { this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); }
From source file:facebook4j.internal.util.z_F4JInternalStringUtilTest.java
@Test public void formatISO8601Datetime() throws Exception { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2012); cal.set(Calendar.MONTH, 5);//w w w. j a va 2 s. com cal.set(Calendar.DAY_OF_MONTH, 15); cal.set(Calendar.HOUR_OF_DAY, 16); cal.set(Calendar.MINUTE, 17); cal.set(Calendar.SECOND, 18); cal.set(Calendar.MILLISECOND, 0); cal.setTimeZone(TimeZone.getTimeZone("JST")); String actual1 = z_F4JInternalStringUtil.formatISO8601Datetime(cal); assertThat(actual1, is("2012-06-15T16:17:18+0900")); cal.setTimeZone(TimeZone.getTimeZone("UTC")); String actual2 = z_F4JInternalStringUtil.formatISO8601Datetime(cal); assertThat(actual2, is("2012-06-15T07:17:18+0000")); //16-9=7 JSONObject json = new JSONObject( "{\"datetime1\": \"" + actual1 + "\", \"datetime2\": \"" + actual2 + "\"}"); Date d1 = z_F4JInternalParseUtil.getISO8601Datetime("datetime1", json); Date d2 = z_F4JInternalParseUtil.getISO8601Datetime("datetime2", json); assertThat(d1, is(d2)); }
From source file:io.apiman.test.integration.rest.apis.metrics.AbstractIntervalMetricsIT.java
@BeforeClass public static void setUpFormatter() throws Exception { formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); }
From source file:fm.audiobox.core.utils.ModelUtil.java
/** * Given a string representing an UTC date provided by AudioBox server, * this method returns a unix timestamp (always in UTC). * * @param simpleDateFormat the simple date format * @param audioboxDate the string date provided by audiobox server. * * @return unix timestamp/* w w w .j a v a2 s .c o m*/ * * @throws ParseException the parse exception */ public static long toUnixTime(SimpleDateFormat simpleDateFormat, String audioboxDate) throws ParseException { simpleDateFormat.applyPattern(AUDIOBOX_DATE_FORMAT); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = simpleDateFormat.parse(audioboxDate); return date.getTime(); }