List of usage examples for java.util Calendar getTimeZone
public TimeZone getTimeZone()
From source file:oscar.oscarDemographic.pageUtil.ImportDemographicDataAction4.java
String getCalDateTime(Calendar c) { if (c == null) return ""; Calendar c1 = Calendar.getInstance(); c1.setTime(new Date()); //Cancel out timezone difference int diff = c.getTimeZone().getRawOffset() - c1.getTimeZone().getRawOffset(); c.add(Calendar.MILLISECOND, diff); //Cancel out daylight saving diff = c.getTimeZone().useDaylightTime() && c.getTimeZone().inDaylightTime(c.getTime()) ? 1 : 0; diff -= c1.getTimeZone().useDaylightTime() && c1.getTimeZone().inDaylightTime(c.getTime()) ? 1 : 0; c.add(Calendar.HOUR, diff);/*from w ww. ja v a 2s. c om*/ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return f.format(c.getTime()); }
From source file:de.escidoc.core.test.EscidocTestBase.java
/** * Gets the last-modification-date attribute of the root element from the document. * // w w w . jav a 2 s. c o m * @param document * The document to retrieve the value from. * @return Returns the attribute value. * @throws Exception * If anything fails. */ public static DateTime getLastModificationDateValue2(final Document document) throws Exception { String dateString = getRootElementAttributeValue(document, "last-modification-date"); if (dateString == null) { return null; } final Calendar calendar = DatatypeConverter.parseDate(dateString); return new DateTime(calendar.getTimeInMillis(), DateTimeZone.forTimeZone(calendar.getTimeZone())); }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIComponent.java
/*********************************************************************************************** * Update the existing Chart referenced by the DAO, by applying the specified datasets, * using all existing channel selections and range selections. * This implementation ASSUMES a ChannelSelector is present. * * @param dao//from www . j a va 2 s .c om * @param datasettype * @param primarydataset * @param secondarydatasets * @param displaylimit * @param domainstartpoint * @param domainendpoint * @param channelselector * @param debug */ public void updateChartForSelection(final ObservatoryInstrumentDAOInterface dao, final DatasetType datasettype, final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final int displaylimit, final int domainstartpoint, final int domainendpoint, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final String SOURCE = "ChartUIComponent.updateChartForSelection() "; if ((dao != null) && (dao.getChartUI() != null) && (dao.getChartUI().getChartPanel() != null) && (dao.getChartUI().getChartPanel().getChart() != null) && (dao.getChartUI().getChartPanel().getChart().getXYPlot() != null) && (datasettype != null) && (primarydataset != null) && (secondarydatasets != null) && (channelselector != null)) { final XYDataset xyNewPrimaryDataset; final List<XYDataset> listNewSecondaryDatasets; final List<XYDataset> listParentSecondaryDatasetForSeries; final Iterator iterOriginalSecondaryDatasets; final Calendar calObservatory; // Either find the Current Observatory calendar, or provide a default calObservatory = ObservatoryInstrumentHelper.getCurrentObservatoryCalendar(REGISTRY.getFramework(), dao, debug); // Create a list of NewSecondaryDatasets for display // Add an appropriate *empty* new dataset for every one existing in the secondary set // and record the parent new Dataset for each Series in each original Dataset // So much complexity just to handle the very few cases of secondary datasets... listNewSecondaryDatasets = new ArrayList<XYDataset>(10); listParentSecondaryDatasetForSeries = new ArrayList<XYDataset>(10); iterOriginalSecondaryDatasets = secondarydatasets.iterator(); while (iterOriginalSecondaryDatasets.hasNext()) { final XYDataset xyDatasetOriginal; xyDatasetOriginal = (XYDataset) iterOriginalSecondaryDatasets.next(); if ((xyDatasetOriginal != null) && (xyDatasetOriginal.getSeriesCount() > 0)) { final XYDataset xyDatasetNew; // Create an empty Dataset to correspond with the original if (datasettype.getName().equals(DatasetType.XY.getName())) { xyDatasetNew = new XYSeriesCollection(); listNewSecondaryDatasets.add(xyDatasetNew); } else if (datasettype.getName().equals(DatasetType.TIMESTAMPED.getName())) { xyDatasetNew = new TimeSeriesCollection(calObservatory.getTimeZone()); listNewSecondaryDatasets.add(xyDatasetNew); } else { xyDatasetNew = new XYSeriesCollection(); listNewSecondaryDatasets.add(xyDatasetNew); } // Record the *same* parent Dataset for each Series in each original Secondary Dataset // This creates a List in channel order, but with references to Datasets not Series for (int i = 0; i < xyDatasetOriginal.getSeriesCount(); i++) { listParentSecondaryDatasetForSeries.add(xyDatasetNew); } } } // Confirm the DatasetType if ((datasettype.getName().equals(DatasetType.XY.getName())) && (primarydataset instanceof XYSeriesCollection)) { final XYSeriesCollection collectionPrimary; // Prepare a new XYSeriesCollection for display xyNewPrimaryDataset = new XYSeriesCollection(); // There should be a collection of <channelcount> XYSeries in the Primary Dataset // but there may also be some in the Secondary Datasets collectionPrimary = (XYSeriesCollection) primarydataset; // ToDo Make this work for ChannelSelector NULL, get channel count from primary and secondaries? Set mode to X1? if ((collectionPrimary.getSeriesCount() > 0) && (collectionPrimary.getSeries() != null) && (channelselector.getChannelSelectionModes() != null)) { LOGGER.debug(debug, SOURCE + "XY domainstartpoint=" + domainstartpoint + " domainendpoint=" + domainendpoint); ChartHelper.dumpXYDataset(debug, calObservatory, collectionPrimary, 4, SOURCE + "XYSeriesCollection --> Original Dataset"); // Find which channels and data range to use this time round for (int intChannelIndex = 0; intChannelIndex < channelselector.getChannelSelectionModes() .size(); intChannelIndex++) { final ChannelSelectionMode selectionMode; selectionMode = channelselector.getChannelSelectionModes().get(intChannelIndex); if (!ChannelSelectionMode.OFF.equals(selectionMode)) { final XYSeries seriesOriginalData; // We needed to know about the secondary datasets in order to get the correct index seriesOriginalData = (XYSeries) ChartHelper.getSeriesForIndex(datasettype, primarydataset, secondarydatasets, intChannelIndex, debug); if (seriesOriginalData != null) { final XYSeries seriesChangedData; final List listOriginalDataItems; int intStartIndex; int intEndIndex; listOriginalDataItems = seriesOriginalData.getItems(); // Prepare a new Series for the changed data, with the same Key seriesChangedData = new XYSeries(seriesOriginalData.getKey()); if (listOriginalDataItems.size() > 0) { // Map the slider values to data indexes intStartIndex = ChartHelper.transformDomainSliderValueToSeriesIndex( ChartUIComponentPlugin.DOMAIN_SLIDER_MINIMUM, ChartUIComponentPlugin.DOMAIN_SLIDER_MAXIMUM, domainstartpoint, DatasetDomainUIComponentInterface.INDEX_LEFT, collectionPrimary.getDomainLowerBound(true), collectionPrimary.getDomainUpperBound(true), DatasetType.XY, calObservatory, seriesOriginalData, debug); intEndIndex = ChartHelper.transformDomainSliderValueToSeriesIndex( ChartUIComponentPlugin.DOMAIN_SLIDER_MINIMUM, ChartUIComponentPlugin.DOMAIN_SLIDER_MAXIMUM, domainendpoint, DatasetDomainUIComponentInterface.INDEX_RIGHT, collectionPrimary.getDomainLowerBound(true), collectionPrimary.getDomainUpperBound(true), DatasetType.XY, calObservatory, seriesOriginalData, debug); if ((intStartIndex == -1) || (intEndIndex == -1)) { // If either index is returned as -1, then there's nothing to do... // ...so stop the for() loop intStartIndex = 0; intEndIndex = 0; } else if (intEndIndex <= intStartIndex) { intEndIndex = intStartIndex + 1; } LOGGER.debug(debug, SOURCE + "before copy of selected series subset [channel=" + intChannelIndex + "] [index.start=" + intStartIndex + "] [index.end=" + intEndIndex + "]"); // Copy over only the selected range from the Slider for (int intDataIndex = intStartIndex; intDataIndex < intEndIndex; intDataIndex++) { final XYDataItem dataOriginalItem; final XYDataItem dataChangedItem; dataOriginalItem = (XYDataItem) listOriginalDataItems.get(intDataIndex); if (!ChannelSelectionMode.X1.equals(selectionMode)) { // Change each value of the series according to the multiplier dataChangedItem = new XYDataItem(dataOriginalItem.getX(), dataOriginalItem.getY().doubleValue() * selectionMode.getMultiplier()); } else { // Just use the whole series unaltered for gain of X1 dataChangedItem = new XYDataItem(dataOriginalItem.getX(), dataOriginalItem.getY()); } seriesChangedData.add(dataChangedItem); } // Did we collect any data for this Series? // If not, place a dummy point at the origin of the *visible* chart if (seriesChangedData.getItemCount() == 0) { // TODO ChartHelper.createDummyXYSeriesDataItemAtOrigin() seriesChangedData.add(new XYDataItem(0, 0)); } // Place the changed series in the correct collection // to correspond with the original if (intChannelIndex < collectionPrimary.getSeriesCount()) { // Simply add the changed Primary series to the PrimaryDataset collection ((XYSeriesCollection) xyNewPrimaryDataset).addSeries(seriesChangedData); } else { // It must be a secondary dataset // Add the changed Secondary series to the parent SecondaryDataset // given by the *secondary* channel index ChartHelper.addSecondarySeries(datasettype, listParentSecondaryDatasetForSeries, seriesChangedData, intChannelIndex - collectionPrimary.getSeriesCount()); } } else { LOGGER.warn(SOURCE + "OriginalData XYSeries unexpectedly NULL"); } } else { // There are no data! Do nothing... LOGGER.warn(SOURCE + "There are no data, so do nothing"); } } } LOGGER.debug(debug, SOURCE + "Update the data shown on existing Chart"); // The outputs are xyNewPrimaryDataset and listNewSecondaryDatasets // This Chart does not use secondary datasets (yet) // Dump the (partial) contents of each Series in the new XYdataset ChartHelper.dumpXYDataset(debug, calObservatory, xyNewPrimaryDataset, 4, SOURCE + "XYSeriesCollection --> setDataset"); dao.getChartUI().getChartPanel().getChart().getXYPlot().setDataset(INDEX_DATA, xyNewPrimaryDataset); } else { LOGGER.error(SOURCE + " The XYSeriesCollection does not have any XYSeries"); } } else if ((datasettype.getName().equals(DatasetType.TIMESTAMPED.getName())) && (primarydataset instanceof TimeSeriesCollection)) { final TimeSeriesCollection collectionPrimary; LOGGER.debug(debug, SOURCE + "TIMESTAMPED domainstartpoint=" + domainstartpoint + " domainendpoint=" + domainendpoint); // Prepare a new TimeSeriesCollection for display xyNewPrimaryDataset = new TimeSeriesCollection(calObservatory.getTimeZone()); // There should be a collection of <channelcount> TimeSeries in the Primary Dataset // but there may also be some in the Secondary Datasets collectionPrimary = (TimeSeriesCollection) primarydataset; if ((collectionPrimary.getSeriesCount() > 0) && (collectionPrimary.getSeries() != null) && (channelselector.getChannelSelectionModes() != null)) { ChartHelper.dumpXYDataset(debug, calObservatory, collectionPrimary, 4, SOURCE + "TimeSeriesCollection PrimaryDataset --> Original Dataset"); // Find which channels and data range to use this time round for (int intChannelIndex = 0; intChannelIndex < channelselector.getChannelSelectionModes() .size(); intChannelIndex++) { final ChannelSelectionMode selectionMode; selectionMode = channelselector.getChannelSelectionModes().get(intChannelIndex); if (!ChannelSelectionMode.OFF.equals(selectionMode)) { final TimeSeries seriesOriginalData; // We needed to know about the secondary datasets in order to get the correct index seriesOriginalData = (TimeSeries) ChartHelper.getSeriesForIndex(datasettype, primarydataset, secondarydatasets, intChannelIndex, debug); if (seriesOriginalData != null) { final List listOriginalDataItems; final TimeSeries seriesChangedData; listOriginalDataItems = seriesOriginalData.getItems(); // Prepare a new Series for the changed data, with the same Key seriesChangedData = new TimeSeries(seriesOriginalData.getKey().toString(), seriesOriginalData.getTimePeriodClass()); if (listOriginalDataItems.size() > 0) { int intStartIndex; int intEndIndex; // Map the slider values to data indexes intStartIndex = ChartHelper.transformDomainSliderValueToSeriesIndex( ChartUIComponentPlugin.DOMAIN_SLIDER_MINIMUM, ChartUIComponentPlugin.DOMAIN_SLIDER_MAXIMUM, domainstartpoint, DatasetDomainUIComponentInterface.INDEX_LEFT, collectionPrimary.getDomainLowerBound(true), collectionPrimary.getDomainUpperBound(true), DatasetType.TIMESTAMPED, calObservatory, seriesOriginalData, debug); intEndIndex = ChartHelper.transformDomainSliderValueToSeriesIndex( ChartUIComponentPlugin.DOMAIN_SLIDER_MINIMUM, ChartUIComponentPlugin.DOMAIN_SLIDER_MAXIMUM, domainendpoint, DatasetDomainUIComponentInterface.INDEX_RIGHT, collectionPrimary.getDomainLowerBound(true), collectionPrimary.getDomainUpperBound(true), DatasetType.TIMESTAMPED, calObservatory, seriesOriginalData, debug); if ((intStartIndex == -1) || (intEndIndex == -1)) { // If either index is returned as -1, then there's nothing to do... // ...so stop the for() loop LOGGER.debug(debug, SOURCE + "Set EndIndex = StartIndex = 0"); intStartIndex = 0; intEndIndex = 0; } else if (intEndIndex <= intStartIndex) { LOGGER.debug(debug, SOURCE + "Correcting EndIndex less than StartIndex"); intEndIndex = intStartIndex + 1; } LOGGER.debug(debug, SOURCE + "before copy of selected series subset [channel=" + intChannelIndex + "] [start_index=" + intStartIndex + "] [end_index=" + intEndIndex + "]"); // Copy over only the selected range from the Slider for (int intDataIndex = intStartIndex; intDataIndex < intEndIndex; intDataIndex++) { final TimeSeriesDataItem dataOriginalItem; final TimeSeriesDataItem dataChangedItem; dataOriginalItem = (TimeSeriesDataItem) listOriginalDataItems .get(intDataIndex); if (!ChannelSelectionMode.X1.equals(selectionMode)) { // Change each value of the series according to the multiplier dataChangedItem = new TimeSeriesDataItem(dataOriginalItem.getPeriod(), dataOriginalItem.getValue().doubleValue() * selectionMode.getMultiplier()); } else { // Just use the whole series unaltered for gain of X1 dataChangedItem = new TimeSeriesDataItem(dataOriginalItem.getPeriod(), dataOriginalItem.getValue().doubleValue()); } seriesChangedData.add(dataChangedItem); } // Did we collect any data for this Series? // If not, place a dummy point at the origin of the *visible* chart if (seriesChangedData.getItemCount() == 0) { seriesChangedData.add(ChartHelper.createDummyTimeSeriesDataItemAtOrigin( collectionPrimary, seriesOriginalData, domainstartpoint, debug)); } // Place the changed series in the correct collection // to correspond with the original if (intChannelIndex < collectionPrimary.getSeriesCount()) { // Simply add the changed Primary series to the PrimaryDataset collection ((TimeSeriesCollection) xyNewPrimaryDataset).addSeries(seriesChangedData); } else { // It must be a secondary dataset // Add the changed Secondary series to the parent SecondaryDataset // given by the *secondary* channel index ChartHelper.addSecondarySeries(datasettype, listParentSecondaryDatasetForSeries, seriesChangedData, intChannelIndex - collectionPrimary.getSeriesCount()); } } else { // There are no data! Do nothing... LOGGER.warn(SOURCE + "There are no data, so do nothing [channel.index=" + intChannelIndex + "]"); } } else { LOGGER.warn(SOURCE + "OriginalData TimeSeries unexpectedly NULL [channel.index=" + intChannelIndex + "]"); } } else { LOGGER.debug(debug, SOURCE + "Channel is OFF [channel.index=" + intChannelIndex + "]"); } } LOGGER.debug(debug, SOURCE + "Update the data shown on existing Chart"); // The outputs are xyNewPrimaryDataset and listNewSecondaryDatasets // This Chart superclass does not use secondary datasets (yet) // Dump the (partial) contents of each Series in the new XYdataset ChartHelper.dumpXYDataset(debug, calObservatory, xyNewPrimaryDataset, 4, SOURCE + "TimeSeriesCollection NewPrimaryDataset --> setDataset"); dao.getChartUI().getChartPanel().getChart().getXYPlot().setDataset(INDEX_DATA, xyNewPrimaryDataset); } else { LOGGER.error(SOURCE + " The TimeSeriesCollection does not have any TimeSeries"); } } else { LOGGER.error(SOURCE + " The Dataset is of an invalid type"); } } else { LOGGER.debug(debug, SOURCE + " Unable to change the Chart - invalid parameters"); } }
From source file:org.exist.xquery.modules.mail.SendEmailFunction.java
/** * Returns the current date and time in an RFC822 format, suitable for an email Date Header * * @return RFC822 formated date and time as a String *//*from w w w . j a v a 2 s. co m*/ private String getDateRFC822() { String dateString = new String(); final Calendar rightNow = Calendar.getInstance(); //Day of the week switch (rightNow.get(Calendar.DAY_OF_WEEK)) { case Calendar.MONDAY: dateString = "Mon"; break; case Calendar.TUESDAY: dateString = "Tue"; break; case Calendar.WEDNESDAY: dateString = "Wed"; break; case Calendar.THURSDAY: dateString = "Thu"; break; case Calendar.FRIDAY: dateString = "Fri"; break; case Calendar.SATURDAY: dateString = "Sat"; break; case Calendar.SUNDAY: dateString = "Sun"; break; } dateString += ", "; //Date dateString += rightNow.get(Calendar.DAY_OF_MONTH); dateString += " "; //Month switch (rightNow.get(Calendar.MONTH)) { case Calendar.JANUARY: dateString += "Jan"; break; case Calendar.FEBRUARY: dateString += "Feb"; break; case Calendar.MARCH: dateString += "Mar"; break; case Calendar.APRIL: dateString += "Apr"; break; case Calendar.MAY: dateString += "May"; break; case Calendar.JUNE: dateString += "Jun"; break; case Calendar.JULY: dateString += "Jul"; break; case Calendar.AUGUST: dateString += "Aug"; break; case Calendar.SEPTEMBER: dateString += "Sep"; break; case Calendar.OCTOBER: dateString += "Oct"; break; case Calendar.NOVEMBER: dateString += "Nov"; break; case Calendar.DECEMBER: dateString += "Dec"; break; } dateString += " "; //Year dateString += rightNow.get(Calendar.YEAR); dateString += " "; //Time String tHour = Integer.toString(rightNow.get(Calendar.HOUR_OF_DAY)); if (tHour.length() == 1) { tHour = "0" + tHour; } String tMinute = Integer.toString(rightNow.get(Calendar.MINUTE)); if (tMinute.length() == 1) { tMinute = "0" + tMinute; } String tSecond = Integer.toString(rightNow.get(Calendar.SECOND)); if (tSecond.length() == 1) { tSecond = "0" + tSecond; } dateString += tHour + ":" + tMinute + ":" + tSecond + " "; //TimeZone Correction String tzSign = new String(); String tzHours = new String(); String tzMinutes = new String(); final TimeZone thisTZ = rightNow.getTimeZone(); int tzOffset = thisTZ.getOffset(rightNow.getTime().getTime()); //get timezone offset in milliseconds tzOffset = (tzOffset / 1000); //convert to seconds tzOffset = (tzOffset / 60); //convert to minutes //Sign if (tzOffset > 1) { tzSign = "+"; } else { tzSign = "-"; tzOffset *= -1; } //Calc Hours and Minutes? if (tzOffset >= 60) { //Minutes and Hours tzHours += (tzOffset / 60); //hours // do we need to prepend a 0 if (tzHours.length() == 1) { tzHours = "0" + tzHours; } tzMinutes += (tzOffset % 60); //minutes // do we need to prepend a 0 if (tzMinutes.length() == 1) { tzMinutes = "0" + tzMinutes; } } else { //Just Minutes tzHours = "00"; tzMinutes += tzOffset; // do we need to prepend a 0 if (tzMinutes.length() == 1) { tzMinutes = "0" + tzMinutes; } } dateString += tzSign + tzHours + tzMinutes; return dateString; }
From source file:edu.ucsb.eucalyptus.cloud.ws.WalrusManager.java
private void writeRenameEvent(EntityManager em, final String eventType, final String account, final String bucketName, final String object_key, final String renameTo, final long syncid, final String reqid, final int objseq) throws EucalyptusCloudException { Session sess = null;/*from w ww . j a va 2 s. c om*/ try { sess = ((Session) em.getDelegate()); } catch (Throwable t) { sess = null; } if ("webApp".equals(eventType)) { final String sql = "insert into web_opt_log(rectime,time,cssact,op,fpth,fsz,file_version,syncid,isfolder,rslt,inst_id,reqid)" + "select ?,to_timestamp(coalesce(value::bigint,0)/1000),?,'Rename',?,size,?,?,content_type='application/x-directory','succ','dummy',? from objects " + "obj left join metadata mtd on obj.object_name=mtd.object_id and mtd.\"name\"='mtime' " + "where object_key = ? AND bucket_name = ? AND owner_id = ? limit 1"; if (sess != null) { sess.doWork(new Work() { public void execute(Connection connection) throws SQLException { PreparedStatement stmt = null; try { stmt = connection.prepareStatement(sql); Calendar c = Calendar.getInstance(); stmt.setTimestamp(1, new Timestamp(c.getTimeInMillis() - c.getTimeZone().getRawOffset())); stmt.setString(2, account); stmt.setString(3, object_key + "||" + renameTo); stmt.setInt(4, objseq); stmt.setLong(5, syncid); stmt.setString(6, reqid); stmt.setString(7, renameTo); stmt.setString(8, bucketName); stmt.setString(9, account); stmt.executeUpdate(); } finally { try { if (stmt != null) stmt.close(); } catch (Throwable t) { /*NOP*/} } } }); } else { Calendar c = Calendar.getInstance(); em.createNativeQuery(sql) .setParameter(1, new Timestamp(c.getTimeInMillis() - c.getTimeZone().getRawOffset())) .setParameter(2, account).setParameter(3, object_key + "||" + renameTo) .setParameter(4, objseq).setParameter(5, syncid).setParameter(6, reqid) .setParameter(7, renameTo).setParameter(8, bucketName).setParameter(9, account) .executeUpdate(); } } else if ("mobileApp".equals(eventType)) { } else { final String sql = "insert into opt_log(rectime,time,cssact,op,fpth,fsz,file_version,syncid,isfolder,rslt,inst_id,reqid) " + "select ?,to_timestamp(coalesce(value::bigint,0)/1000),?,'Rename',?,size,?,?,content_type='application/x-directory','succ','dummy',? from objects " + "obj left join metadata mtd on obj.object_name=mtd.object_id and mtd.\"name\"='mtime' " + "where object_key = ? AND bucket_name = ? AND owner_id = ? limit 1"; if (sess != null) { sess.doWork(new Work() { public void execute(Connection connection) throws SQLException { PreparedStatement stmt = null; try { stmt = connection.prepareStatement(sql); Calendar c = Calendar.getInstance(); stmt.setTimestamp(1, new Timestamp(c.getTimeInMillis() - c.getTimeZone().getRawOffset())); stmt.setString(2, account); stmt.setString(3, object_key + "||" + renameTo); stmt.setInt(4, objseq); stmt.setLong(5, syncid); stmt.setString(6, reqid); stmt.setString(7, renameTo); stmt.setString(8, bucketName); stmt.setString(9, account); stmt.executeUpdate(); } finally { try { if (stmt != null) stmt.close(); } catch (Throwable t) { /*NOP*/} } } }); } else { Calendar c = Calendar.getInstance(); em.createNativeQuery(sql) .setParameter(1, new Timestamp(c.getTimeInMillis() - c.getTimeZone().getRawOffset())) .setParameter(2, account).setParameter(3, object_key + "||" + renameTo) .setParameter(4, objseq).setParameter(5, syncid).setParameter(6, reqid) .setParameter(7, renameTo).setParameter(8, bucketName).setParameter(9, account) .executeUpdate(); } } }
From source file:com.redhat.rhn.frontend.xmlrpc.system.SystemHandler.java
private Date convertLocalToUtc(Date in) { Calendar c = Calendar.getInstance(); c.setTime(in);//from w w w . ja v a 2 s.c o m TimeZone z = c.getTimeZone(); int offset = z.getRawOffset(); if (z.inDaylightTime(in)) { offset += z.getDSTSavings(); } int offsetHrs = offset / 1000 / 60 / 60; int offsetMins = offset / 1000 / 60 % 60; c.add(Calendar.HOUR_OF_DAY, (-offsetHrs)); c.add(Calendar.MINUTE, (-offsetMins)); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }