Example usage for java.text DateFormat getDateInstance

List of usage examples for java.text DateFormat getDateInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateInstance.

Prototype

public static final DateFormat getDateInstance() 

Source Link

Document

Gets the date formatter with the default formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:org.opencms.jsp.util.CmsJspElFunctions.java

/**
 * Returns a Date created from an Object.<p>
 * //  www  .jav a 2 s .c o  m
 * <ul>
 * <li>The Object is first checked if it is a {@link Date} already, if so it is casted and returned unchanged.
 * <li>If not, the input is checked if it is a {@link Long}, and if so the Date is created from the Long value.
 * <li>If it's not a Date and not a Long, the Object is transformed to a String and then it's tried 
 * to parse a Long out of the String. 
 * <li>If this fails, it is tried to parse as a Date using the
 * default date formatting. 
 * <li>If this also fails, a new Date is returned that has been initialized with 0.<p>
 * </ul>
 * 
 * @param input the Object to create a Date from
 * 
 * @return a Date created from the given Object
 */
public static Date convertDate(Object input) {

    Date result;
    if (input instanceof Date) {
        result = (Date) input;
    } else if (input instanceof Long) {
        result = new Date(((Long) input).longValue());
    } else {
        String str = String.valueOf(input);
        try {
            // treat the input as a String
            long l = Long.parseLong(str);
            result = new Date(l);
        } catch (NumberFormatException e) {
            try {
                // try to parse String as a Date
                result = DateFormat.getDateInstance().parse(str);
            } catch (ParseException e1) {
                result = null;
            }
            if (result == null) {
                // use default date if parsing fails
                result = new Date(0);
            }
        }
    }
    return result;
}

From source file:org.dharmaseed.android.PlayTalkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_talk);

    // Turn on action bar up/home button
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//  w w  w  .ja  v a2s .c  o  m

    // Get the ID of the talk to display
    Intent i = getIntent();
    talkID = (int) i.getLongExtra(NavigationActivity.TALK_DETAIL_EXTRA, 0);

    dbManager = DBManager.getInstance(this);

    // only hit the DB again if we know the talk is different than the one
    // we have saved.
    // for example, if the user selects a talk, exits, and re-opens it, no need
    // to hit the DB again, since we already have that talk saved
    if (talk == null || talk.getId() != talkID) {
        Cursor cursor = getCursor();
        if (cursor.moveToFirst()) {
            // convert DB result to an object
            talk = new Talk(cursor);
            talk.setId(talkID);
        } else {
            Log.e(LOG_TAG, "Could not look up talk, id=" + talkID);
            cursor.close();
            return;
        }
        cursor.close();
    } // else we already have the talk, just re-draw the page

    // Set the talk title
    TextView titleView = (TextView) findViewById(R.id.play_talk_talk_title);
    titleView.setText(talk.getTitle());

    // Set the teacher name
    TextView teacherView = (TextView) findViewById(R.id.play_talk_teacher);
    teacherView.setText(talk.getTeacherName());

    // Set the center name
    TextView centerView = (TextView) findViewById(R.id.play_talk_center);
    centerView.setText(talk.getCenterName());

    // Set the talk description
    TextView descriptionView = (TextView) findViewById(R.id.play_talk_talk_description);
    descriptionView.setText(talk.getDescription());

    // Set teacher photo
    String photoFilename = talk.getPhotoFileName();
    ImageView photoView = (ImageView) findViewById(R.id.play_talk_teacher_photo);
    Log.i(LOG_TAG, "photoFilename: " + photoFilename);
    try {
        FileInputStream photo = openFileInput(photoFilename);
        photoView.setImageBitmap(BitmapFactory.decodeStream(photo));
    } catch (FileNotFoundException e) {
        Drawable icon = ContextCompat.getDrawable(this, R.drawable.dharmaseed_icon);
        photoView.setImageDrawable(icon);
    }

    // set the image of the download button based on whether the talk is
    // downloaded or not
    toggleDownloadImage();

    // Set date
    TextView dateView = (TextView) findViewById(R.id.play_talk_date);
    String recDate = talk.getDate();
    SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        dateView.setText(DateFormat.getDateInstance().format(parser.parse(recDate)));
    } catch (ParseException e) {
        dateView.setText("");
        Log.w(LOG_TAG, "Could not parse talk date for talk ID " + talkID);
    }

    // Get/create a persistent fragment to manage the MediaPlayer instance
    FragmentManager fm = getSupportFragmentManager();
    talkPlayerFragment = (TalkPlayerFragment) fm.findFragmentByTag("talkPlayerFragment");
    if (talkPlayerFragment == null) {
        // add the fragment
        talkPlayerFragment = new TalkPlayerFragment();
        fm.beginTransaction().add(talkPlayerFragment, "talkPlayerFragment").commit();
    } else if (talkPlayerFragment.getMediaPlayer().isPlaying()) {
        setPPButton("ic_media_pause");
    }

    // Set the talk duration
    final TextView durationView = (TextView) findViewById(R.id.play_talk_talk_duration);
    double duration = talk.getDurationInMinutes();
    String durationStr = DateUtils.formatElapsedTime((long) (duration * 60));
    durationView.setText(durationStr);

    // Start a handler to periodically update the seek bar and talk time
    final SeekBar seekBar = (SeekBar) findViewById(R.id.play_talk_seek_bar);
    seekBar.setMax((int) (duration * 60 * 1000));
    userDraggingSeekBar = false;
    userSeekBarPosition = 0;
    seekBar.setOnSeekBarChangeListener(this);
    final Handler handler = new Handler();
    final MediaPlayer mediaPlayer = talkPlayerFragment.getMediaPlayer();
    handler.post(new Runnable() {
        @Override
        public void run() {
            handler.postDelayed(this, 1000);
            if (talkPlayerFragment.getMediaPrepared() && !userDraggingSeekBar) {
                try {
                    int pos = mediaPlayer.getCurrentPosition();
                    int mpDuration = mediaPlayer.getDuration();
                    seekBar.setMax(mpDuration);
                    seekBar.setProgress(pos);
                    String posStr = DateUtils.formatElapsedTime(pos / 1000);
                    String mpDurStr = DateUtils.formatElapsedTime(mpDuration / 1000);
                    durationView.setText(posStr + "/" + mpDurStr);
                } catch (IllegalStateException e) {
                }
            }
        }
    });
}

From source file:org.jini.commands.utils.DateCalc.java

private Date parseDate(String date) {
    Date d = null;//from w  w w . j a  v  a  2  s.c  o  m

    DateFormat df = DateFormat.getDateInstance();
    try {
        SimpleDateFormat dateform = new SimpleDateFormat("dd.MM.yyyy");
        d = dateform.parse(date);
    } catch (Exception e) {

        this.setJcError(true);
        this.addErrorMessages("Error : [" + date + "] is not a date");
        //System.out.println("Error: " + e.toString());
    }

    return d;
}

From source file:com.sample.searchprofile.portlet.JSPPortlet.java

public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException {

    String command = req.getParameter("command");

    int id = 0;//from www  .j  av a  2 s .  c  o  m
    int userId = 0;

    try {
        id = Integer.parseInt(req.getParameter("id"));
        //userId = Integer.parseInt(req.getParameter("userId"));
    } catch (Exception e) {
    }

    // user relatesd
    String name = req.getParameter("first_name");
    String userLastName = req.getParameter("last_name");
    String userCompanyName = req.getParameter("userCompanyName");
    String userPositionCompany = req.getParameter("userPositionCompany");
    String userMobilePhone = req.getParameter("telephone_user");
    String userWorkPhone = req.getParameter("telefax_user");
    // company related
    String partnerDescription = req.getParameter("partnerDescription");
    int partnerNumber = 1;
    if (req.getParameter("partnerNumber") != null)
        partnerNumber = Integer.parseInt(req.getParameter("partnerNumber"));
    String telephone = req.getParameter("telephone");
    String telefax = req.getParameter("telefax");
    String mail = req.getParameter("mail");
    String street1 = req.getParameter("street1");
    String street2 = req.getParameter("street2");
    String zipcode = req.getParameter("zipcode");
    String city = req.getParameter("city");
    String state_province = req.getParameter("state_province");
    String country = req.getParameter("country");
    String micrositeAdress = req.getParameter("micrositeAdress");
    String company_website = req.getParameter("company_website");
    String noemployees = req.getParameter("noemployees");
    String geographic_coverage = req.getParameter("geographic_coverage");
    String parent_company_name = req.getParameter("parent_company_name");
    String country_parent_company = req.getParameter("country_parent_company");
    String channel_partner_since = req.getParameter("channel_partner_since");
    String primary_business_type = req.getParameter("primary_business_type");
    String secondary_business_type = req.getParameter("secondary_business_type");
    String sap_solution_focus = req.getParameter("sap_solution_focus");
    String industry_micro_vertical_focus = req.getParameter("industry_micro_vertical_focus");

    String last_review_Date = req.getParameter("last_review_Date");
    String reviewed_by = req.getParameter("reviewed_by");
    String profile_added = "";//req.getParameter("profile_added");
    String date_updated = "";//req.getParameter("date_updated");
    String modified_by = req.getParameter("modified_by");
    String[] SAPitems = req.getParameterValues("sap_solution_focus");
    String[] industry = req.getParameterValues("industry");
    String[] countryCoverage = req.getParameterValues("country_coverage");

    //search related
    String[] SAPitems_search = req.getParameterValues("sap_solution_focus_search");
    String industrySearch = req.getParameter("industry_search");
    String[] countryCoverage_search = req.getParameterValues("country_coverage_search");
    String country_search = req.getParameter("country_search");
    String primary_business_type_search = req.getParameter("primary_business_type_search");
    if (command == null)
        return;
    try {
        DateFormat df = DateFormat.getDateInstance();

        if (command.equals("add")) {
            // user
            // user adress + phone

            // company
            CompanyItem companyItem = new CompanyItem();

            companyItem.setName(userCompanyName);
            companyItem.setDescription(partnerDescription);
            companyItem.setCompanyNo(partnerNumber);
            companyItem.setCompanyFriendlySite(micrositeAdress);
            companyItem.setCompanySite(company_website);
            if (noemployees != null && !noemployees.isEmpty())
                companyItem.setCompanyEmpNo(Integer.parseInt(noemployees));
            companyItem.setParentCompanyName(parent_company_name);
            if (channel_partner_since != null && !channel_partner_since.isEmpty())
                companyItem.setYear(Integer.parseInt(channel_partner_since));
            Date tempDate = new Date();

            companyItem.setDateUpdated(new Date());
            companyItem.setDateLastReview(new Date());
            companyItem.setDateUpdated(new Date());

            if (last_review_Date != null && !last_review_Date.isEmpty()) {
                try {
                    tempDate = df.parse(last_review_Date);
                    String value = tempDate.toString();
                    companyItem.setDateLastReview(tempDate);
                } catch (ParseException ex) {
                }
            }

            companyItem.setReviewedBy(reviewed_by);
            companyItem.setModifiedBy(modified_by);

            CompanyItemDAO.addCompanyItem(companyItem);

            int adressId = companyItem.getAdressId();
            int compAddedId = companyItem.getAdressId();
            AdressItem adressItem = null;
            if (adressId <= 0) {
                adressItem = new AdressItem();
                adressItem.setCompanyId(companyItem.getId());
                adressItem.setStreet1(street1);
                adressItem.setStreet1(street2);
                adressItem.setCity(city);
                adressItem.setZip(zipcode);
                adressItem.setStateregionname(state_province);
                adressItem.setMail(mail);
                // countryId
                if (country != "") {
                    CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country);
                    adressItem.setCountryId(countryItemTemp.getId());
                }
                AdressItemDAO.addAdressItem(adressItem);

                if (telephone != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telephone, 1);
                if (telefax != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telefax, 2);
                AdressItemDAO.updateAdressItem(adressItem);
            }

            //2 . SAP solution focus
            if (SAPitems != null) {
                for (int loopIndex = 0; loopIndex < SAPitems.length; loopIndex++) {
                    System.out.println(SAPitems[loopIndex]);
                }
            }
            CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems);
            // 3. Industry
            if (industry != null) {
                for (int loopIndex = 0; loopIndex < industry.length; loopIndex++) {
                    System.out.println(industry[loopIndex]);
                }
            }
            CompanyUtil.updateCompanyIndustriesList(companyItem, industry);
            //4. primary business type -- primary_business_type
            if (primary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1);
            //5. secondary business type - secondary_business_type
            if (secondary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2);
            //6. country coverage

            if (countryCoverage != null) {
                for (int loopIndex = 0; loopIndex < countryCoverage.length; loopIndex++) {
                    System.out.println(countryCoverage[loopIndex]);
                }
            }
            CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage);

        } else if (command.equals("edit")) {
            //user
            CompanyItem companyItem = CompanyItemDAO.getCompanyItem(id);

            companyItem.setName(userCompanyName);
            companyItem.setDescription(partnerDescription);
            companyItem.setCompanyNo(partnerNumber);
            companyItem.setCompanyFriendlySite(micrositeAdress);
            companyItem.setCompanySite(company_website);
            if (noemployees != null && !noemployees.isEmpty())
                companyItem.setCompanyEmpNo(Integer.parseInt(noemployees));
            companyItem.setParentCompanyName(parent_company_name);
            if (channel_partner_since != null && !channel_partner_since.isEmpty())
                companyItem.setYear(Integer.parseInt(channel_partner_since));
            if (country_parent_company != "") {
                CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country_parent_company);
                if (countryItemTemp != null)
                    companyItem.setCountryRegistrationId(countryItemTemp.getId());
            }

            Date date = new Date();
            try {
                date = df.parse(last_review_Date);
            } catch (ParseException ex) {
            }
            /*companyItem.setDateLastReview(date);
            try {date = df.parse(profile_added);
            }catch (ParseException ex){
            }
            companyItem.setDateCreated(date);*/
            companyItem.setDateUpdated(new Date());
            companyItem.setReviewedBy(reviewed_by);
            companyItem.setModifiedBy(modified_by);

            // update childs
            //1 . adress + phone
            int adressId = companyItem.getAdressId();
            AdressItem adressItem = null;
            boolean bIsNew = false;
            if (adressId > 0) {
                adressItem = AdressItemDAO.getAdressItem(adressId);
            } else {
                adressItem = new AdressItem();
                bIsNew = true;
            }
            if (adressItem != null) {
                adressItem.setCompanyId(id);
                adressItem.setStreet1(street1);
                adressItem.setStreet2(street2);
                adressItem.setCity(city);
                adressItem.setZip(zipcode);
                adressItem.setStateregionname(state_province);
                adressItem.setMail(mail);
                // countryId
                if (country != "") {
                    CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country);
                    adressItem.setCountryId(countryItemTemp.getId());
                }

                if (bIsNew) {
                    AdressItemDAO.addAdressItem(adressItem);
                    companyItem.setAdressId(adressItem.getId());
                }
                if (telephone != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telephone, 1);
                if (telefax != "")
                    AdressItemDAO.updatePhoneItem(adressItem, telefax, 2);
                AdressItemDAO.updateAdressItem(adressItem);
            }
            // Do update in main table
            CompanyItemDAO.updateCompanyItem(companyItem);

            //2 . SAP solution focus
            if (SAPitems != null) {
                for (int loopIndex = 0; loopIndex < SAPitems.length; loopIndex++) {
                    System.out.println(SAPitems[loopIndex]);
                }
            }
            CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems);
            // 3. Industry
            if (industry != null) {
                for (int loopIndex = 0; loopIndex < industry.length; loopIndex++) {
                    System.out.println(industry[loopIndex]);
                }
            }
            CompanyUtil.updateCompanyIndustriesList(companyItem, industry);
            //4. primary business type -- primary_business_type
            if (primary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1);
            //5. secondary business type - secondary_business_type
            if (secondary_business_type != null)
                CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2);
            //6. country coverage

            if (countryCoverage != null) {
                for (int loopIndex = 0; loopIndex < countryCoverage.length; loopIndex++) {
                    System.out.println(countryCoverage[loopIndex]);
                }
            }
            CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage);
        } else if (command.equals("delete")) {
            CompanyItemDAO.deleteCompanyItem(id);
        } else if (command.equals("search")) {
            ;
        } else if (command.equals("viewall")) {
            ;
        }
        System.out.println("iese");
    } catch (SQLException sqle) {
        throw new PortletException(sqle);
    }

}

From source file:de.atomfrede.tools.evalutation.tools.plot.ui.wizard.simple.SimplePlotWizard.java

@Override
public void onFinished(List<WizardPage> arg0, WizardSettings arg1) {
    this.setVisible(false);

    busyDialog = new BusyDialog("Please wait while plots are generated...");
    busyDialog.setLocationRelativeTo(DialogUtil.getInstance().getFrame());
    DialogUtil.getInstance().showStandardDialog(busyDialog);

    SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {

        @Override/*from  w w  w  .j av a2  s  .  co m*/
        protected Object doInBackground() throws Exception {
            StringBuilder fileNameBuilder = new StringBuilder();
            // first collect all datasets
            List<XYDatasetWrapper> wrappers = ((DatasetSelectionWizardPage) pages.get(1)).getDatasetWrappers();
            XYDatasetWrapper[] wrappersArray = new XYDatasetWrapper[wrappers.size()];

            int width = ((FileSelectionWizardPage) pages.get(0)).getEnteredWidth();
            int height = ((FileSelectionWizardPage) pages.get(0)).getEnteredHeight();

            int i = 0;
            for (XYDatasetWrapper wrapper : wrappers) {
                wrappersArray[i] = wrapper;
                if (i == 0)
                    fileNameBuilder.append(wrapper.getSeriesName());
                else
                    fileNameBuilder.append("-" + wrapper.getSeriesName());
                i++;
            }

            String date = DateFormat.getDateInstance().format(new Date());

            String fileName = date + "-" + fileNameBuilder.toString();
            CustomSimplePlot timePlot = new CustomSimplePlot(dataFile, fileName, width, height, wrappersArray);
            try {
                timePlot.plot();
            } catch (Exception e) {
                log.error("The requested data could not be plotted", e);
            }
            try {
                Desktop.getDesktop().open(new File(Options.getOutputFolder(), fileName + ".pdf"));
            } catch (IOException e) {
                log.error("Generated file could not be opened.", e);
            }

            return null;
        }

        @Override
        protected void done() {
            busyDialog.dispose();
            dispose();
        }

    };

    worker.execute();

}

From source file:com.nextgis.maplibui.control.DateTime.java

@Override
public void init(Field field, Bundle savedState, Cursor featureCursor) {
    if (null != field) {
        mFieldName = field.getName();//from   w  w  w  . j a  va2  s.  co  m
    }

    switch (mPickerType) {

    case GeoConstants.FTDate:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateInstance();
        break;

    case GeoConstants.FTTime:
        mDateFormat = (SimpleDateFormat) DateFormat.getTimeInstance();
        break;

    default:
        mPickerType = GeoConstants.FTDateTime;
    case GeoConstants.FTDateTime:
        mDateFormat = (SimpleDateFormat) DateFormat.getDateTimeInstance();
        break;
    }

    String text = "";

    if (ControlHelper.hasKey(savedState, mFieldName)) {
        mValue = savedState.getLong(ControlHelper.getSavedStateKey(mFieldName));
    } else if (null != featureCursor) {
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0) {
            mValue = featureCursor.getLong(column);
        }
    }

    if (null != mValue) {
        text = getText();
    }

    setText(text);
    setSingleLine(true);
    setFocusable(false);
    setOnClickListener(getDateUpdateWatcher(mPickerType));

    String pattern = mDateFormat.toLocalizedPattern();
    setHint(pattern);
}

From source file:org.noise_planet.noisecapture.MainActivity.java

/**
 * @return Version information on this application
 * @throws PackageManager.NameNotFoundException
 *//* ww w  . ja v  a  2s  .c  o m*/
public static String getVersionString(Activity activity) throws PackageManager.NameNotFoundException {
    String versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName;
    Date buildDate = new Date(BuildConfig.TIMESTAMP);
    String gitHash = BuildConfig.GITHASH;
    if (gitHash == null || gitHash.isEmpty()) {
        gitHash = "";
    } else {
        gitHash = gitHash.substring(0, 7);
    }
    return activity.getString(R.string.title_appversion, versionName,
            DateFormat.getDateInstance().format(buildDate), gitHash);
}

From source file:op.tools.SYSCalendar.java

public static void handleDateFocusLost(FocusEvent evt, DateMidnight min, DateMidnight max) {
    DateTime dt;/*  w  w  w.  j a  v a 2s  .co m*/
    if (max == null) {
        max = new DateMidnight();
    }
    try {
        dt = new DateTime(parseDate(((JTextField) evt.getSource()).getText()));
    } catch (NumberFormatException ex) {
        OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.wrongdate")));
        dt = new DateTime();
    }
    if (dt.isAfter(max)) {
        dt = new DateTime();
        DisplayMessage dm = new DisplayMessage(
                dt.isAfterNow() ? SYSTools.xx("misc.msg.futuredate") : SYSTools.xx("misc.msg.wrongdate"));
        OPDE.getDisplayManager().addSubMessage(dm);
    }
    if (dt.isBefore(min)) {
        dt = new DateTime();
        OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.DateTooOld")));
    }

    ((JTextField) evt.getSource()).setText(DateFormat.getDateInstance().format(dt.toDate()));
}

From source file:op.care.med.inventory.DlgNewStocks.java

private void txtExpiresFocusLost(FocusEvent e) {
    try {//from www.  ja va 2s.c  o m
        DateTime myExpiry = SYSCalendar.parseExpiryDate(txtExpires.getText());
        if (myExpiry.isBeforeNow()) {
            throw new Exception("date must not be in the past");
        }
        expiry = myExpiry.toDate();
        txtExpires.setText(DateFormat.getDateInstance().format(expiry));
    } catch (Exception ex) {
        expiry = null;
        txtExpires.setText(null);
    }
}

From source file:de.atomfrede.tools.evalutation.tools.plot.ui.wizard.time.TimePlotWizard.java

@Override
public void onFinished(List<WizardPage> arg0, WizardSettings arg1) {
    this.setVisible(false);

    busyDialog = new BusyDialog("Please wait while plots are generated...");
    busyDialog.setLocationRelativeTo(DialogUtil.getInstance().getFrame());
    DialogUtil.getInstance().showStandardDialog(busyDialog);

    SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {

        @Override// w w w. j  a va2s  . c  o  m
        protected Object doInBackground() throws Exception {
            StringBuilder fileNameBuilder = new StringBuilder();
            // first collect all datasets
            List<TimeDatasetWrapper> wrappers = ((DatasetSelectionWizardPage) pages.get(1))
                    .getTimeDatasetWrappers();
            TimeDatasetWrapper[] wrappersArray = new TimeDatasetWrapper[wrappers.size()];

            int width = ((TimeFileSelectionPage) pages.get(0)).getEnteredWidth();
            int height = ((TimeFileSelectionPage) pages.get(0)).getEnteredHeight();

            int i = 0;
            for (TimeDatasetWrapper wrapper : wrappers) {
                wrappersArray[i] = wrapper;
                if (i == 0)
                    fileNameBuilder.append(wrapper.getSeriesName());
                else
                    fileNameBuilder.append("-" + wrapper.getSeriesName());
                i++;
            }

            String date = DateFormat.getDateInstance().format(new Date());

            String fileName = date + "-" + fileNameBuilder.toString();
            CustomTimePlot timePlot = new CustomTimePlot(dataFile, fileName, width, height, wrappersArray);
            try {
                timePlot.plot();
            } catch (Exception e) {
                log.error("The requested data could not be plotted", e);
            }
            try {
                Desktop.getDesktop().open(new File(Options.getOutputFolder(), fileName + ".pdf"));
            } catch (IOException e) {
                log.error("Generated file could not be opened.", e);
            }

            return null;
        }

        @Override
        protected void done() {
            busyDialog.dispose();
            dispose();
        }

    };

    worker.execute();
}