Example usage for java.util SimpleTimeZone SimpleTimeZone

List of usage examples for java.util SimpleTimeZone SimpleTimeZone

Introduction

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

Prototype

public SimpleTimeZone(int rawOffset, String ID) 

Source Link

Document

Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID with no daylight saving time schedule.

Usage

From source file:org.dasein.cloud.aws.storage.Glacier.java

private static long parseTimestamp(String timestamp) {
    if (timestamp == null) {
        return -1;
    }//  w ww .  j  a  v  a2  s .  c o  m
    long creationTs;
    SimpleDateFormat fmt;

    // some response dates have MS component, some do not.
    if (timestamp.contains(".")) {
        fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    } else {
        fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    }
    Calendar cal = Calendar.getInstance(new SimpleTimeZone(0, "GMT"));
    fmt.setCalendar(cal);
    try {
        creationTs = fmt.parse(timestamp).getTime();
    } catch (ParseException e) {
        creationTs = System.currentTimeMillis();
    }
    return creationTs;
}

From source file:org.rdv.rbnb.RBNBExport.java

/**
 * Export the channels from the RBNB server to the specified file. The data
 * will be exported between the two time bounds provided.
 * /*from  w ww  .  j  av  a2 s . c  o  m*/
 * @param channels   the list of channels to export
 * @param dataFile   the data file to write the data to
 * @param startTime  the start time of the data to export
 * @param endTime    the end time of the data to export
 * @param listener   a listener to post progress to
 * @since            1.3
 */
private synchronized void exportData(List<String> numericChannels, File dataFile,
        List<String> multimediaChannels, File dataDirectory, double startTime, double endTime,
        ProgressListener listener) {

    if (listener == null) {
        // create dummy listener if needed
        listener = new ProgressListener() {
            public void postProgress(double progress) {
            }

            public void postCompletion() {
            }

            public void postError(String errorMessage) {
            }
        };
    }

    if (numericChannels == null) {
        numericChannels = new ArrayList<String>();
    }

    if (multimediaChannels == null) {
        multimediaChannels = new ArrayList<String>();
    }

    if (numericChannels.size() == 0 && multimediaChannels.size() == 0) {
        listener.postError("No channels were specified.");
        return;
    }

    if (numericChannels.size() > 0) {
        if (dataFile == null) {
            listener.postError("The data file is not specified.");
            return;
        } else if (dataFile.isDirectory()) {
            listener.postError("The data file is a directory.");
            return;
        }
    }

    if (multimediaChannels.size() > 0) {
        if (dataDirectory == null) {
            listener.postError("Data directory is invalid.");
            return;
        } else if (!dataDirectory.isDirectory()) {
            listener.postError("the data directory isn't a directory.");
            return;
        }
    }

    if (startTime > endTime) {
        listener.postError("The start time must be greater than the end time");
        return;
    }

    double time = startTime;

    try {
        Sink sink = new Sink();
        sink.OpenRBNBConnection(rbnbHostName + ":" + rbnbPortNumber, "RDVExport");
        ChannelMap cmap = new ChannelMap();
        for (int i = 0; i < numericChannels.size(); i++) {
            cmap.Add(numericChannels.get(i));
        }
        for (int i = 0; i < multimediaChannels.size(); i++) {
            cmap.Add(multimediaChannels.get(i));
        }

        BufferedWriter fileWriter = null;
        if (numericChannels.size() > 0) {
            fileWriter = new BufferedWriter(new FileWriter(dataFile));
        }

        if (fileWriter != null) {
            fileWriter.write("Start time: " + RBNBUtilities.secondsToISO8601(startTime) + "\r\n");
            fileWriter.write("End time: " + RBNBUtilities.secondsToISO8601(endTime) + "\r\n");
            fileWriter.write(
                    "Export time: " + RBNBUtilities.millisecondsToISO8601(System.currentTimeMillis()) + "\r\n");
            fileWriter.write("\r\n");

            // write channel names
            fileWriter.write("Time\t");
            for (int i = 0; i < numericChannels.size(); i++) {
                String channel = numericChannels.get(i);
                String[] channelParts = channel.split("/");
                fileWriter.write(channelParts[channelParts.length - 1]);
                if (i != numericChannels.size() - 1) {
                    fileWriter.write('\t');
                }
            }
            fileWriter.write("\r\n");

            // fetch channel metadata and write channel units (if available)
            sink.RequestRegistration(cmap);
            ChannelMap rmap = sink.Fetch(-1);

            fileWriter.write("Seconds\t");
            for (int i = 0; i < numericChannels.size(); i++) {
                String channel = numericChannels.get(i);
                String unit = null;
                int index = rmap.GetIndex(channel);
                String[] metadata = rmap.GetUserInfo(index).split(",");
                for (int j = 0; j < metadata.length; j++) {
                    String[] elements = metadata[j].split("=");
                    if (elements.length == 2 && elements[0].equals("units")) {
                        unit = elements[1];
                        break;
                    }
                }
                if (unit != null) {
                    fileWriter.write(unit);
                }
                fileWriter.write('\t');
            }
            fileWriter.write("\r\n");
        }

        listener.postProgress(0);

        double dataStartTime = -1;

        while (time < endTime && !cancelExport) {
            double duration = 2;
            if (time + duration > endTime) {
                duration = endTime - time;
            }

            sink.Request(cmap, time, duration, "absolute");
            ChannelMap dmap = sink.Fetch(-1);

            ArrayList<Sample> samples = new ArrayList<Sample>();
            for (int i = 0; i < numericChannels.size(); i++) {
                String channel = numericChannels.get(i);
                int index = dmap.GetIndex(channel);
                if (index != -1) {
                    int type = dmap.GetType(index);
                    double[] times = dmap.GetTimes(index);
                    for (int j = 0; j < times.length; j++) {
                        Sample sample;

                        /* Skip data that isn't in the requested time bounds. This is due
                         * to overlap between requests for data. 
                         */
                        if (times[j] > startTime && times[j] <= time) {
                            continue;
                        }

                        switch (type) {
                        case ChannelMap.TYPE_INT32:
                            sample = new Sample(channel, dmap.GetDataAsInt32(index)[j], times[j]);
                            break;
                        case ChannelMap.TYPE_INT64:
                            sample = new Sample(channel, dmap.GetDataAsInt64(index)[j], times[j]);
                            break;
                        case ChannelMap.TYPE_FLOAT32:
                            sample = new Sample(channel, dmap.GetDataAsFloat32(index)[j], times[j]);
                            break;
                        case ChannelMap.TYPE_FLOAT64:
                            sample = new Sample(channel, dmap.GetDataAsFloat64(index)[j], times[j]);
                            break;
                        default:
                            sample = new Sample(channel, "", times[j]);
                        }
                        samples.add(sample);
                    }
                }
            }

            Collections.sort(samples, new SampleTimeComparator());

            Iterator<Sample> it = samples.iterator();
            boolean end = false;

            Sample s = null;
            if (it.hasNext()) {
                s = it.next();
            } else {
                end = true;
            }

            while (!end) {
                double t = s.getTime();

                if (dataStartTime == -1) {
                    dataStartTime = t;
                }

                fileWriter.write(Double.toString(t - dataStartTime) + "\t");
                for (int i = 0; i < numericChannels.size(); i++) {
                    String c = numericChannels.get(i);
                    if (c.equals(s.getChannel()) && t == s.getTime()) {
                        fileWriter.write(s.getData());
                        if (it.hasNext()) {
                            s = it.next();
                        } else {
                            fileWriter.write("\r\n");
                            end = true;
                            break;
                        }
                    }
                    if (i == numericChannels.size() - 1) {
                        fileWriter.write("\r\n");
                    } else {
                        fileWriter.write('\t');
                    }
                }
            }

            String videoChannel, fileName;
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH.mm.ss.SSS'Z'");
            dateFormat.setTimeZone(new SimpleTimeZone(0, "UTC"));

            for (int i = 0; i < multimediaChannels.size(); i++) {
                videoChannel = multimediaChannels.get(i);
                int index = dmap.GetIndex(videoChannel);
                if (index != -1) {
                    int type = dmap.GetType(index);
                    if (type == ChannelMap.TYPE_BYTEARRAY) {
                        double[] times = dmap.GetTimes(index);
                        byte[][] datas = dmap.GetDataAsByteArray(index);
                        for (int j = 0; j < times.length; j++) {
                            byte[] data = datas[j];
                            // write image file
                            try {
                                fileName = videoChannel;
                                if (fileName.endsWith(".jpg")) {
                                    fileName = fileName.substring(0, fileName.length() - 4);
                                }
                                if (fileName.endsWith("/video")) {
                                    fileName = fileName.substring(0, fileName.length() - 6);
                                }
                                fileName = fileName.replace("/", "-");

                                String timeStamp = dateFormat.format(new Date((long) (times[j] * 1000)));

                                fileName += "_" + timeStamp + ".jpg";
                                File outputFile = new File(dataDirectory, fileName);
                                FileOutputStream out = new FileOutputStream(outputFile);
                                out.write(data);
                                out.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }

            time += duration;

            listener.postProgress((time - startTime) / (endTime - startTime));
        }

        if (fileWriter != null) {
            fileWriter.close();
        }

        sink.CloseRBNBConnection();

        if (cancelExport) {
            dataFile.delete();
            listener.postError("Export canceled.");
        } else {
            listener.postCompletion();
        }
    } catch (Exception e) {
        e.printStackTrace();
        listener.postError("Error exporting data: " + e.getMessage());
        return;
    }

    cancelExport = false;

    return;
}

From source file:com.krawler.common.timezone.Timezone.java

public static String[] getTzonetoGmt(String date1, String tzUser) throws ServiceException, ParseException {

    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);//ww w. j  a v  a  2 s  .c om
    format1.setCalendar(cal1);
    String dateArr[] = date1.split(" ");
    if (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(" ");
    if (results[1].equals("00:00:00")) {
        results[1] = "00:00:01";
    }
    return results;
}

From source file:com.openddal.test.BaseTestCase.java

/**
 * Check if two values are equal, and if not throw an exception.
 *
 * @param expected the expected value// w  w w  .  j a v  a  2s . c  o m
 * @param actual the actual value
 * @throws AssertionError if the values are not equal
 */
public void assertEquals(java.util.Date expected, java.util.Date actual) {
    if (expected != actual && !expected.equals(actual)) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        SimpleTimeZone gmt = new SimpleTimeZone(0, "Z");
        df.setTimeZone(gmt);
        fail("Expected: " + df.format(expected) + " actual: " + df.format(actual));
    }
}

From source file:edu.fullerton.viewerplugin.PluginSupport.java

/**
 * Generate a JFreeChart TimeSeries object from a ChanDataBuffer
 * Note:  the time axis is in UTC.  For GPS or delta T use XY series.
 * @param dbuf - ldvw data buffer//from w ww  .j  a  v  a  2  s . c  om
 * @param legend - plot legend for this series
 * @return JFreeChart time series for adding to a plot
 */
public TimeSeries getTimeSeries(ChanDataBuffer dbuf, String legend, int sum) throws LdvTableException {
    sum = sum < 1 ? 1 : sum;
    TimeSeries ts;
    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 += sum) {
        float td = 0.f;
        int nsum = 0;
        for (int j = 0; j < sum && i + j < dbuf.getDataLength(); j++) {
            td += data[i + j];
            nsum++;
        }
        td /= nsum;

        long curMs = Math.round(msPerSample * i + startMs);
        Date t = new Date(curMs);
        ts.addOrUpdate(new Millisecond(t, utctz), td);
        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), td);
        }
    }
    return ts;
}

From source file:edu.dlnu.liuwenpeng.EachMintueTransactionSupport.SegmentedTimeline.java

/**    
* Returns the milliseconds for midnight of the first Monday after    
* 1-Jan-1900, ignoring daylight savings.    
*    /*from w w  w  .j  av a 2  s. c o  m*/
* @return The milliseconds.    
*    
* @since 1.0.7    
*/
public static long firstMondayAfter1900() {
    int offset = TimeZone.getDefault().getRawOffset();
    TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset);

    // calculate midnight of first monday after 1/1/1900 relative to    
    // current locale    
    Calendar cal = new GregorianCalendar(z);
    cal.set(1900, 0, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
        cal.add(Calendar.DATE, 1);
    }
    //return cal.getTimeInMillis();    
    // preceding code won't work with JDK 1.3    
    return cal.getTime().getTime();
}

From source file:edu.dlnu.liuwenpeng.EachMintueTransactionSupport.SegmentedTimeline.java

/**    
* Constructs a new segmented timeline, optionaly using another segmented    
* timeline as its base. This chaining of SegmentedTimelines allows further    
* segmentation into smaller timelines.    
*    // www. j  a va2 s .c o m
* If a base    
*    
* @param segmentSize the size of a segment in ms. This time unit will be    
*        used to compute the included and excluded segments of the    
*        timeline.    
* @param segmentsIncluded Number of consecutive segments to include.    
* @param segmentsExcluded Number of consecutive segments to exclude.    
*/
public SegmentedTimeline(long segmentSize, int segmentsIncluded, int segmentsExcluded) {

    this.segmentSize = segmentSize;
    this.segmentsIncluded = segmentsIncluded;
    this.segmentsExcluded = segmentsExcluded;

    this.groupSegmentCount = this.segmentsIncluded + this.segmentsExcluded;
    this.segmentsIncludedSize = this.segmentsIncluded * this.segmentSize;
    this.segmentsExcludedSize = this.segmentsExcluded * this.segmentSize;
    this.segmentsGroupSize = this.segmentsIncludedSize + this.segmentsExcludedSize;
    int offset = TimeZone.getDefault().getRawOffset();
    TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset);
    this.workingCalendarNoDST = new GregorianCalendar(z, Locale.getDefault());
}

From source file:com.qut.middleware.esoe.sso.impl.AuthenticationAuthorityProcessorFuncTest.java

/**
 * Test method for/*www .  j  ava 2 s . c  o  m*/
 * {@link com.qut.middleware.esoe.sso.impl.SSOProcessorImpl#execute(com.qut.middleware.esoe.sso.bean.SSOProcessorData)}.
 * Tests for successful sso authn response creation within an allowed time skew, should set AuthnContextClassRef to
 * PasswordProtectedTransport
 */
@Test
public void testExecute2() throws Exception {
    String authnIdentifier = "12345-12345";
    List<String> entities = new ArrayList<String>();
    entities.add("12345-12345");

    authAuthorityProcessor = new SSOProcessorImpl(samlValidator, sessionsProcessor, this.metadata,
            identifierGenerator, metadata, keyStoreResolver, identifierMap, handlers, properties);
    data.setHttpRequest(request);
    data.setHttpResponse(response);
    data.setSessionID("1234567890");
    data.setIssuerID("12345-12345");
    data.setSamlBinding(BindingConstants.httpPost);

    data.setRequestDocument(generateValidRequest(true, 0));

    expect(metadata.resolveKey(this.spepKeyAlias)).andReturn(pk).atLeastOnce();
    expect(sessionsProcessor.getQuery()).andReturn(query).atLeastOnce();
    expect(query.queryAuthnSession("1234567890")).andReturn(principal).atLeastOnce();

    entityData = createMock(EntityData.class);
    spepRole = createMock(SPEPRole.class);
    expect(entityData.getRoleData(SPEPRole.class)).andReturn(spepRole).anyTimes();
    expect(spepRole.getNameIDFormatList()).andReturn(this.defaultSupportedType).anyTimes();
    expect(spepRole.getAssertionConsumerServiceEndpoint(BindingConstants.httpPost, 0))
            .andReturn("https://spep.qut.edu.au/sso/aa").anyTimes();

    expect(metadata.getEntityData(this.issuer)).andReturn(entityData).anyTimes();
    expect(metadata.getEntityRoleData(this.issuer, SPEPRole.class)).andReturn(spepRole).anyTimes();

    expect(principal.getSAMLAuthnIdentifier()).andReturn(authnIdentifier).atLeastOnce();
    //   expect(principal.getActiveEntityList()).andReturn(entities).atLeastOnce();

    /* User originally authenticated basically within the same request timeframe */
    expect(principal.getAuthnTimestamp()).andReturn(System.currentTimeMillis() - 200).atLeastOnce();
    expect(principal.getAuthenticationContextClass())
            .andReturn(AuthenticationContextConstants.passwordProtectedTransport).atLeastOnce();
    expect(principal.getPrincipalAuthnIdentifier()).andReturn("beddoes").atLeastOnce();

    //principal.addEntitySessionIndex((String) notNull(), (String) notNull());

    TimeZone utc = new SimpleTimeZone(0, ConfigurationConstants.timeZone);
    GregorianCalendar cal = new GregorianCalendar(utc);
    // add skew offset that will keep notonorafter within allowable session range
    cal.add(Calendar.SECOND, 1000);
    expect(principal.getSessionNotOnOrAfter())
            .andReturn(new XMLGregorianCalendarImpl(cal).toGregorianCalendar().getTimeInMillis() + 2000000)
            .atLeastOnce();

    expect(sessionsProcessor.getUpdate()).andReturn(update).anyTimes();
    expect(identifierGenerator.generateSAMLSessionID()).andReturn("_1234567-1234567-samlsessionid").anyTimes();

    update.addEntitySessionIndex((Principal) notNull(), "1234567890", this.issuer);

    expect(request.getServerName()).andReturn("http://esoe-unittest.code").anyTimes();
    expect(identifierGenerator.generateSAMLID()).andReturn("_1234567-1234567").once();
    expect(identifierGenerator.generateSAMLID()).andReturn("_890123-890123").once();

    setUpMock();

    SSOProcessor.result result = authAuthorityProcessor.execute(data);

    assertEquals("Ensure success result for response creation", SSOProcessor.result.SSOGenerationSuccessful,
            result);

    Response samlResponse = unmarshaller.unMarshallSigned(data.getResponseDocument());
    assertTrue("Asserts the response document InReplyTo field is the same value as the original request id",
            samlResponse.getInResponseTo().equals(this.issuer));

    // now validate it
    this.samlValidator.getResponseValidator().validate(samlResponse);

    tearDownMock();
}

From source file:com.qut.middleware.delegator.openid.authn.impl.AuthnProcessorImpl.java

/**
 * Generates an XML gregorian calendar instance based on 0 offset UTC current time.
 *
 * @return The created calendar for the current UTC time, else null if an error
 * occurs creating the calendar.//w ww  .  ja v a 2s .  c om
 */
private XMLGregorianCalendar generateXMLCalendar() {
    GregorianCalendar calendar;

    SimpleTimeZone tz = new SimpleTimeZone(0, ConfigurationConstants.timeZone);
    calendar = new GregorianCalendar(tz);

    try {
        DatatypeFactory factory = DatatypeFactory.newInstance();
        return factory.newXMLGregorianCalendar(calendar);
    } catch (DatatypeConfigurationException e) {
        return null;
    }
}

From source file:com.lastsoft.plog.adapter.GameAdapter.java

public void playPopup(View v, final int position) {

    try {/*from  ww  w  .  ja v  a2s .  c  om*/
        InputMethodManager inputManager = (InputMethodManager) mActivity
                .getSystemService(Context.INPUT_METHOD_SERVICE);

        inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception ignored) {
    }

    PopupMenu popup = new PopupMenu(mActivity, v);

    MenuInflater inflater = popup.getMenuInflater();

    if (games.get(position).expansionFlag == true) {
        inflater.inflate(R.menu.game_expansion_overflow, popup.getMenu());
    } else {
        inflater.inflate(R.menu.game_overflow, popup.getMenu());
    }
    if (games.get(position).gameBGGID == null || games.get(position).gameBGGID.equals("")) {
        popup.getMenu().removeItem(R.id.update_bgg);
        popup.getMenu().removeItem(R.id.open_bgg);
        popup.getMenu().removeItem(R.id.add_bgg);
    }
    if (games.get(position).gameBoxImage == null || games.get(position).gameBoxImage.equals("")) {
        popup.getMenu().removeItem(R.id.view_box_photo);
    }
    if (games.get(position).taggedToPlay <= 0) {
        popup.getMenu().removeItem(R.id.remove_bucket_list);
    } else {
        popup.getMenu().removeItem(R.id.add_bucket_list);
    }

    SharedPreferences app_preferences;
    app_preferences = PreferenceManager.getDefaultSharedPreferences(mActivity);
    long currentDefaultPlayer = app_preferences.getLong("defaultPlayer", -1);
    if (games.get(position).collectionFlag || currentDefaultPlayer == -1) {
        popup.getMenu().removeItem(R.id.add_bgg);
    }

    //check if this game has been played
    //if so, can't delete
    if (GamesPerPlay.hasGameBeenPlayed(games.get(position))) {
        popup.getMenu().removeItem(R.id.delete_game);
    }
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.delete_game:
                ((MainActivity) mActivity).deleteGame(games.get(position).getId());
                return true;
            case R.id.add_tenbyten:
                ((MainActivity) mActivity).addToTenXTen(games.get(position).getId());
                return true;
            case R.id.view_plays:
                if (games.get(position).expansionFlag == true) {
                    ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 9, fragmentName,
                            currentYear);
                } else {
                    ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 0, fragmentName,
                            currentYear);
                }
                return true;
            case R.id.open_bgg:
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://bgg.cc/boardgame/" + games.get(position).gameBGGID));
                mActivity.startActivity(browserIntent);
                return true;
            case R.id.update_bgg:
                mPosition = position;
                if (games.get(position).expansionFlag == true) {
                    ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, true, -1);
                } else {
                    ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, false, -1);
                }
                return true;
            case R.id.add_bgg:
                mPosition = position;
                ((MainActivity) mActivity).updateGameViaBGG(games.get(position).gameName,
                        games.get(position).gameBGGID, "", true, false);
                return true;
            case R.id.add_box_photo:
                ((GamesFragment) mFragment).captureBox(games.get(position));
                return true;
            case R.id.view_box_photo:
                String[] photoParts = games.get(position).gameBoxImage.split("/");
                File newFile = new File(
                        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                                + "/Plog/",
                        photoParts[photoParts.length - 1]);
                Uri contentUri = FileProvider.getUriForFile(mActivity.getApplicationContext(),
                        "com.lastsoft.plog.fileprovider", newFile);
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setDataAndType(contentUri, "image/*");
                intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                mActivity.startActivity(intent);
                return true;
            case R.id.add_bucket_list:
                String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
                // if no ids were returned, something is wrong. get out.
                //if (ids.length == 0)
                //    System.exit(0);

                // begin output
                //System.out.println("Current Time");

                // create a Eastern Standard Time time zone
                SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);

                // set up rules for daylight savings time
                pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
                pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

                // create a GregorianCalendar with the Pacific Daylight time zone
                // and the current date and time
                Calendar calendar = new GregorianCalendar(pdt);
                Date trialTime = new Date();
                calendar.setTime(trialTime);
                int i = (int) (calendar.getTime().getTime() / 1000);
                games.get(position).taggedToPlay = i;
                games.get(position).save();

                Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout,
                        games.get(position).gameName + mActivity.getString(R.string.added_to_bl),
                        Snackbar.LENGTH_LONG)
                        .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                games.get(position).taggedToPlay = 0;
                                games.get(position).save();
                                if (playListType == 2) {
                                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                                }
                            }
                        }).show(); // Do not forget to show!

                return true;
            case R.id.remove_bucket_list:
                final int taggedToPlay = games.get(position).taggedToPlay;
                final Game gameToUndo = games.get(position);
                games.get(position).taggedToPlay = 0;
                games.get(position).save();

                Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout,
                        games.get(position).gameName + mActivity.getString(R.string.removed_from_bl),
                        Snackbar.LENGTH_LONG)
                        .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                gameToUndo.taggedToPlay = taggedToPlay;
                                gameToUndo.save();
                                if (playListType == 2) {
                                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                                }
                            }
                        }).show(); // Do not forget to show!
                if (playListType == 2) {
                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                }
                return true;
            default:
                return false;
            }
        }
    }

    );
    popup.show();
}