Example usage for org.joda.time.format DateTimeFormat shortDateTime

List of usage examples for org.joda.time.format DateTimeFormat shortDateTime

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormat shortDateTime.

Prototype

public static DateTimeFormatter shortDateTime() 

Source Link

Document

Creates a format that outputs a short datetime format.

Usage

From source file:azkaban.app.Scheduler.java

License:Apache License

private ScheduledFuture<?> schedule(final ScheduledJob schedJob, boolean saveResults) {
    // fail fast if there is a problem with this job
    _jobManager.validateJob(schedJob.getId());

    Duration wait = new Duration(new DateTime(), schedJob.getScheduledExecution());
    if (wait.getMillis() < -1000) {
        logger.warn("Job " + schedJob.getId() + " is scheduled for "
                + DateTimeFormat.shortDateTime().print(schedJob.getScheduledExecution()) + " which is "
                + (PeriodFormat.getDefault().print(wait.toPeriod()))
                + " in the past, adjusting scheduled date to now.");
        wait = new Duration(0);
    }/*from   w  ww .j  av  a2s  . c om*/

    // mark the job as scheduled
    _scheduled.put(schedJob.getId(), schedJob);

    if (saveResults) {
        try {
            saveSchedule();
        } catch (IOException e) {
            throw new RuntimeException("Error saving schedule after scheduling job " + schedJob.getId());
        }
    }

    ScheduledRunnable runnable = new ScheduledRunnable(schedJob);
    schedJob.setScheduledRunnable(runnable);
    return _executor.schedule(runnable, wait.getMillis(), TimeUnit.MILLISECONDS);
}

From source file:com.atlassian.theplugin.idea.ui.CommentPanel.java

License:Apache License

public CommentPanel(int cmtNumber, final JIRAComment comment, final ServerData server, JTabbedPane tabs,
        IssueDetailsToolWindow.IssuePanel ip) {
    setOpaque(true);//w ww.  ja  va2s .  co m
    setBackground(com.intellij.util.ui.UIUtil.getTextFieldBackground());

    int upperMargin = cmtNumber == 1 ? 0 : COMMENT_GAP;

    setLayout(new GridBagLayout());
    GridBagConstraints gbc;

    JEditorPane commentBody = new JEditorPane();
    btnShowHide = new ShowHideButton(commentBody, this);
    HeaderListener headerListener = new HeaderListener();

    gbc = new GridBagConstraints();
    gbc.gridx++;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(upperMargin, 0, 0, 0);
    add(btnShowHide, gbc);

    gbc.gridx++;
    gbc.insets = new Insets(upperMargin, Constants.DIALOG_MARGIN / 2, 0, 0);
    UserLabel ul = new UserLabel();
    ul.setUserName(server != null ? server.getUrl() : "", comment.getAuthorFullName(), comment.getAuthor(),
            false);
    ul.setFont(ul.getFont().deriveFont(Font.BOLD));
    add(ul, gbc);

    final JLabel hyphen = new WhiteLabel();
    hyphen.setText("-");
    gbc.gridx++;
    gbc.insets = new Insets(upperMargin, Constants.DIALOG_MARGIN / 2, 0, Constants.DIALOG_MARGIN / 2);
    add(hyphen, gbc);

    final JLabel creationDate = new WhiteLabel();
    creationDate.setForeground(Color.GRAY);
    creationDate.setFont(creationDate.getFont().deriveFont(Font.ITALIC));

    //      DateFormat df = new SimpleDateFormat("EEE MMM d HH:mm:ss Z yyyy", Locale.US);
    //      DateFormat dfo = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);

    //        DateTimeFormatter dft = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss Z yyyy").withLocale(Locale.US);
    DateTimeFormatter dfto = DateTimeFormat.shortDateTime().withLocale(Locale.US);
    String t;
    //      try {
    t = dfto.print(new DateTime(comment.getCreationDate()));
    //                    t = dfo.format(df.parse(comment.getCreationDate().getTime().toString()));
    //      } catch (java.text.ParseException e) {
    //         t = "Invalid date: " + comment.getCreationDate().getTime().toString();
    //      }

    creationDate.setText(t);
    gbc.gridx++;
    gbc.insets = new Insets(upperMargin, 0, 0, 0);
    add(creationDate, gbc);

    String dehtmlizedBody = Html2text.translate(comment.getBody());
    if (StackTraceDetector.containsStackTrace(dehtmlizedBody)) {
        int stackTraceCounter = ip.incrementStackTraceCounter();
        tabs.add("Comment Stack Trace #" + (++stackTraceCounter),
                new StackTracePanel(dehtmlizedBody, ip.getProject()));

        gbc.gridx++;
        gbc.insets = new Insets(upperMargin, Constants.DIALOG_MARGIN / 2, 0, 0);
        JLabel traceNumber = new WhiteLabel();
        traceNumber.setText("Stack Trace #" + stackTraceCounter);
        traceNumber.setForeground(Color.RED);

        add(traceNumber, gbc);
    }

    // filler
    gbc.gridx++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    JPanel filler = new JPanel();
    filler.setBackground(com.intellij.util.ui.UIUtil.getTextFieldBackground());
    filler.setOpaque(true);
    gbc.insets = new Insets(upperMargin, 0, 0, 0);
    add(filler, gbc);

    int gridwidth = gbc.gridx + 1;

    commentBody.setEditable(false);
    commentBody.setOpaque(true);
    commentBody.setBackground(com.intellij.util.ui.UIUtil.getTextFieldBackground());
    commentBody.setMargin(new Insets(0, 2 * Constants.DIALOG_MARGIN, 0, 0));
    commentBody.setContentType("text/html");
    commentBody.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    // JEditorPane does not do XHTML :(
    String bodyFixed = comment.getBody().replace("/>", ">");
    commentBody.setText("<html><head></head><body>" + bodyFixed + "</body></html>");
    commentBody.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && e.getURL() != null) {
                BrowserUtil.launchBrowser(e.getURL().toString());
            }
        }
    });
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gridwidth;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(0, 0, 0, 0);
    add(commentBody, gbc);

    addMouseListener(headerListener);
}

From source file:com.goodhuddle.huddle.web.site.handlebars.helper.DateTimeHelper.java

License:Open Source License

public DateTimeHelper() {
    defaultDateFormat = DateTimeFormat.shortDate();
    defaultTimeFormat = DateTimeFormat.shortTime();
    defaultDateTimeFormat = DateTimeFormat.shortDateTime();
}

From source file:com.helger.datetime.format.PDTFormatter.java

License:Apache License

/**
 * Get the short date time formatter for the passed locale.
 *
 * @param aDisplayLocale//from  w w w. jav  a  2  s.  c o  m
 *        The display locale to be used. May be <code>null</code>.
 * @return The created date time formatter. Never <code>null</code>.
 */
@Nonnull
public static DateTimeFormatter getShortFormatterDateTime(@Nullable final Locale aDisplayLocale) {
    return getWithLocaleAndChrono(DateTimeFormat.shortDateTime(), aDisplayLocale);
}

From source file:com.vityuk.ginger.provider.format.JodaTimeUtils.java

License:Apache License

private static DateTimeFormatter createJodaDateFormatter(FormatType formatType, DateFormatStyle formatStyle) {
    switch (formatType) {
    case TIME://from w  ww.  j  a va  2s  .  c o m
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortTime();
        case MEDIUM:
            return DateTimeFormat.mediumTime();
        case LONG:
            return DateTimeFormat.longTime();
        case FULL:
            return DateTimeFormat.fullTime();
        case DEFAULT:
            return ISODateTimeFormat.time();
        }
    case DATE:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDate();
        case MEDIUM:
            return DateTimeFormat.mediumDate();
        case LONG:
            return DateTimeFormat.longDate();
        case FULL:
            return DateTimeFormat.fullDate();
        case DEFAULT:
            return ISODateTimeFormat.date();
        }
    case DATETIME:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDateTime();
        case MEDIUM:
            return DateTimeFormat.mediumDateTime();
        case LONG:
            return DateTimeFormat.longDateTime();
        case FULL:
            return DateTimeFormat.fullDateTime();
        case DEFAULT:
            return ISODateTimeFormat.dateTime();
        }
    }

    throw new IllegalArgumentException();
}

From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java

License:MIT License

private void export() {
    if (refreshing) {
        Toast.makeText(getActivity(), R.string.account_no_concurrent, Toast.LENGTH_LONG).show();
        if (!refreshing) {
            refresh();//  w w  w. j av  a2s.c o m
        }
        return;
    }

    Context ctx = getActivity() != null ? getActivity() : OpacClient.getEmergencyContext();
    AccountDataSource adatasource = new AccountDataSource(ctx);
    AccountData data = adatasource.getCachedAccountData(account);
    LocalDateTime dt = new LocalDateTime(adatasource.getCachedAccountDataTime(account));

    if (data == null)
        return;

    StringBuilder string = new StringBuilder();

    DateTimeFormatter fmt1 = DateTimeFormat.shortDateTime()
            .withLocale(getResources().getConfiguration().locale);
    DateTimeFormatter fmt2 = DateTimeFormat.shortDate().withLocale(getResources().getConfiguration().locale);
    String dateStr = fmt1.print(dt);
    string.append(getResources().getString(R.string.accountdata_export_header, account.getLabel(), dateStr));
    string.append("\n\n");
    string.append(getResources().getString(R.string.lent_head));
    string.append("\n\n");
    for (LentItem item : data.getLent()) {
        appendIfNotEmpty(string, item.getTitle(), R.string.accountdata_title);
        appendIfNotEmpty(string, item.getAuthor(), R.string.accountdata_author);
        appendIfNotEmpty(string, item.getFormat(), R.string.accountdata_format);
        appendIfNotEmpty(string, item.getStatus(), R.string.accountdata_status);
        appendIfNotEmpty(string, item.getBarcode(), R.string.accountdata_lent_barcode);
        if (item.getDeadline() != null) {
            appendIfNotEmpty(string, fmt2.print(item.getDeadline()), R.string.accountdata_lent_deadline);
        }
        appendIfNotEmpty(string, item.getHomeBranch(), R.string.accountdata_lent_home_branch);
        appendIfNotEmpty(string, item.getLendingBranch(), R.string.accountdata_lent_lending_branch);
        string.append("\n");
    }

    if (data.getLent().size() == 0) {
        string.append(getResources().getString(R.string.lent_none));
    }

    string.append(getResources().getString(R.string.reservations_head));
    string.append("\n\n");
    for (ReservedItem item : data.getReservations()) {
        appendIfNotEmpty(string, item.getTitle(), R.string.accountdata_title);
        appendIfNotEmpty(string, item.getAuthor(), R.string.accountdata_author);
        appendIfNotEmpty(string, item.getFormat(), R.string.accountdata_format);
        appendIfNotEmpty(string, item.getStatus(), R.string.accountdata_status);
        if (item.getReadyDate() != null) {
            appendIfNotEmpty(string, fmt2.print(item.getReadyDate()), R.string.accountdata_reserved_ready_date);
        }
        if (item.getExpirationDate() != null) {
            appendIfNotEmpty(string, fmt2.print(item.getExpirationDate()),
                    R.string.accountdata_reserved_expiration_date);
        }
        appendIfNotEmpty(string, item.getBranch(), R.string.accountdata_reserved_branch);
        string.append("\n");
    }

    if (data.getReservations().size() == 0) {
        string.append(getResources().getString(R.string.reservations_none));
    }

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, string.toString());
    sendIntent.setType("text/plain");
    startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share_dialog_select)));
}

From source file:de.sub.goobi.forms.MassImportForm.java

License:Open Source License

/**
 * Convert data./*from   ww w  .  j  a va 2 s. c o  m*/
 *
 * @return String
 */
public String convertData() throws IOException, DataException {
    this.processList = new ArrayList<>();
    if (StringUtils.isEmpty(currentPlugin)) {
        Helper.setFehlerMeldung("missingPlugin");
        return null;
    }
    if (testForData()) {
        List<ImportObject> answer = new ArrayList<>();
        Batch batch = null;

        // found list with ids
        Prefs prefs = serviceManager.getRulesetService().getPreferences(this.template.getRuleset());
        String tempfolder = ConfigCore.getParameter("tempfolder");
        this.plugin.setImportFolder(tempfolder);
        this.plugin.setPrefs(prefs);
        this.plugin.setOpacCatalogue(this.getOpacCatalogue());
        this.plugin.setKitodoConfigDirectory(ConfigCore.getKitodoConfigDirectory());

        if (StringUtils.isNotEmpty(this.idList)) {
            List<String> ids = this.plugin.splitIds(this.idList);
            List<Record> recordList = new ArrayList<>();
            for (String id : ids) {
                Record r = new Record();
                r.setData(id);
                r.setId(id);
                r.setCollections(this.digitalCollections);
                recordList.add(r);
            }

            answer = this.plugin.generateFiles(recordList);
        } else if (this.importFile != null) {
            this.plugin.setFile(this.importFile);
            List<Record> recordList = this.plugin.generateRecordsFromFile();
            for (Record r : recordList) {
                r.setCollections(this.digitalCollections);
            }
            answer = this.plugin.generateFiles(recordList);
        } else if (StringUtils.isNotEmpty(this.records)) {
            List<Record> recordList = this.plugin.splitRecords(this.records);
            for (Record r : recordList) {
                r.setCollections(this.digitalCollections);
            }
            answer = this.plugin.generateFiles(recordList);
        } else if (this.selectedFilenames.size() > 0) {
            List<Record> recordList = this.plugin.generateRecordsFromFilenames(this.selectedFilenames);
            for (Record r : recordList) {
                r.setCollections(this.digitalCollections);
            }
            answer = this.plugin.generateFiles(recordList);

        }

        if (answer.size() > 1) {
            if (importFile != null) {
                List<String> args = Arrays
                        .asList(new String[] { FilenameUtils.getBaseName(importFile.getAbsolutePath()),
                                DateTimeFormat.shortDateTime().print(new DateTime()) });
                batch = new Batch(Helper.getTranslation("importedBatchLabel", args), Type.LOGISTIC);
            } else {
                batch = new Batch();
            }
        }

        for (ImportObject io : answer) {
            if (batch != null) {
                io.getBatches().add(batch);
            }
            if (io.getImportReturnValue().equals(ImportReturnValue.ExportFinished)) {
                Process p = JobCreation.generateProcess(io, this.template);
                if (p == null) {
                    if (io.getImportFileName() != null
                            && !serviceManager.getFileService().getFileName(io.getImportFileName()).isEmpty()
                            && selectedFilenames != null && !selectedFilenames.isEmpty()) {
                        if (selectedFilenames.contains(io.getImportFileName())) {
                            selectedFilenames.remove(io.getImportFileName());
                        }
                    }
                    Helper.setFehlerMeldung(
                            "import failed for " + io.getProcessTitle() + ", process generation failed");

                } else {
                    Helper.setMeldung(
                            ImportReturnValue.ExportFinished.getValue() + " for " + io.getProcessTitle());
                    this.processList.add(p);
                }
            } else {
                List<String> param = new ArrayList<>();
                param.add(io.getProcessTitle());
                param.add(io.getErrorMessage());
                Helper.setFehlerMeldung(Helper.getTranslation("importFailedError", param));
                if (io.getImportFileName() != null
                        && !serviceManager.getFileService().getFileName(io.getImportFileName()).isEmpty()
                        && selectedFilenames != null && !selectedFilenames.isEmpty()) {
                    if (selectedFilenames.contains(io.getImportFileName())) {
                        selectedFilenames.remove(io.getImportFileName());
                    }
                }
            }
        }
        if (answer.size() != this.processList.size()) {
            // some error on process generation, don't go to next page
            return null;
        }
    } else {
        Helper.setFehlerMeldung("missingData");
        return null;
    }
    this.idList = null;
    if (this.importFile != null) {
        this.importFile.delete();
        this.importFile = null;
    }
    if (selectedFilenames != null && !selectedFilenames.isEmpty()) {
        this.plugin.deleteFiles(this.selectedFilenames);
    }
    this.records = "";
    return "/pages/MassImportFormPage3";
}

From source file:gobblin.data.management.version.TimestampedDatasetVersion.java

License:Apache License

@Override
public String toString() {
    return "Version " + this.version.toString(DateTimeFormat.shortDateTime()) + " at path " + this.path;
}

From source file:me.vertretungsplan.additionalinfo.BaseIcalParser.java

License:Mozilla Public License

@Override
public AdditionalInfo getAdditionalInfo() throws IOException {
    AdditionalInfo info = new AdditionalInfo();
    info.setTitle(getTitle());/*from   w  w w. j a  va2s. c om*/

    String rawdata = httpGet(getIcalUrl(), "UTF-8");

    if (shouldStripTimezoneInfo()) {
        Pattern pattern = Pattern.compile("BEGIN:VTIMEZONE.*END:VTIMEZONE", Pattern.DOTALL);
        rawdata = pattern.matcher(rawdata).replaceAll("");
    }

    DateTime now = DateTime.now().withTimeAtStartOfDay();
    List<ICalendar> icals = Biweekly.parse(rawdata).all();

    List<Event> events = new ArrayList<>();
    for (ICalendar ical : icals) {
        for (VEvent event : ical.getEvents()) {
            Event item = new Event();

            TimeZone timezoneStart = getTimeZoneStart(ical, event);

            if (event.getDescription() != null) {
                item.description = event.getDescription().getValue();
            }
            if (event.getSummary() != null) {
                item.summary = event.getSummary().getValue();
            }
            if (event.getDateStart() != null) {
                item.startDate = new DateTime(event.getDateStart().getValue());
                item.startHasTime = event.getDateStart().getValue().hasTime();
            } else {
                continue;
            }
            if (event.getDateEnd() != null) {
                item.endDate = new DateTime(event.getDateEnd().getValue());
                item.endHasTime = event.getDateEnd().getValue().hasTime();
            }
            if (event.getLocation() != null) {
                item.location = event.getLocation().getValue();
            }
            if (event.getUrl() != null) {
                item.url = event.getUrl().getValue();
            }

            if (event.getRecurrenceRule() == null && item.endDate != null
                    && (item.endDate.compareTo(now) < 0)) {
                continue;
            } else if (event.getRecurrenceRule() == null && (item.startDate.compareTo(now) < 0)) {
                continue;
            }
            if (event.getRecurrenceRule() != null && event.getRecurrenceRule().getValue().getUntil() != null
                    && event.getRecurrenceRule().getValue().getUntil().compareTo(now.toDate()) < 0) {
                continue;
            }

            if (event.getRecurrenceRule() != null) {
                Duration duration = null;
                if (event.getDateEnd() != null) {
                    duration = new Duration(new DateTime(event.getDateStart().getValue()),
                            new DateTime(event.getDateEnd().getValue()));
                }

                DateIterator iterator = event.getDateIterator(timezoneStart);
                while (iterator.hasNext()) {
                    Date date = iterator.next();
                    Event reccitem = item.clone();
                    reccitem.startDate = new DateTime(date);
                    reccitem.endDate = reccitem.startDate.plus(duration);

                    if (item.startDate.equals(reccitem.startDate))
                        continue;

                    if (item.endDate != null && (item.endDate.compareTo(now) < 0)) {
                        continue;
                    } else if (item.endDate == null && (item.startDate.compareTo(now) < 0)) {
                        continue;
                    }

                    events.add(reccitem);
                }
            }

            if (item.endDate != null && (item.endDate.compareTo(now) < 0)) {
                continue;
            } else if (item.endDate == null && (item.startDate.compareTo(now) < 0)) {
                continue;
            }

            events.add(item);
        }
    }
    Collections.sort(events, new Comparator<Event>() {
        @Override
        public int compare(Event o1, Event o2) {
            return o1.startDate.compareTo(o2.startDate);
        }
    });

    StringBuilder content = new StringBuilder();

    int count = 0;

    DateTimeFormatter fmtDt = DateTimeFormat.shortDateTime().withLocale(Locale.GERMANY);
    DateTimeFormatter fmtD = DateTimeFormat.shortDate().withLocale(Locale.GERMANY);
    DateTimeFormatter fmtT = DateTimeFormat.shortTime().withLocale(Locale.GERMANY);

    for (Event item : events) {
        if (count >= getMaxItemsCount()) {
            break;
        } else if (count != 0) {
            content.append("<br><br>\n\n");
        }

        DateTime start = item.startDate;

        if (item.endDate != null) {
            DateTime end = item.endDate;

            if (!item.endHasTime) {
                end = end.minusDays(1);
            }

            content.append((item.startHasTime ? fmtDt : fmtD).print(start));
            if (!end.equals(start)) {
                content.append(" - ");
                if (item.startHasTime && item.endHasTime && end.toLocalDate().equals(start.toLocalDate())) {
                    content.append(fmtT.print(end));
                } else {
                    content.append((item.endHasTime ? fmtDt : fmtD).print(end));
                }
            }
        } else {
            content.append(fmtDt.print(start));
        }
        content.append("<br>\n");

        content.append("<b>");
        content.append(item.summary);
        content.append("</b>");

        count++;
    }

    info.setText(content.toString());

    return info;
}

From source file:net.oneandone.stool.History.java

License:Apache License

@Override
public void doInvoke(Stage s) throws Exception {
    List<LogEntry> logEntries;
    int counter;//from   w  w w  .jav  a2  s  . c  o m
    String id;

    logEntries = readLog(s.shared().join("log/stool.log"));
    counter = 1;
    id = null;
    for (LogEntry entry : logEntries) {
        if (entry.logger.equals("IN")) {
            if (detail == -1 || detail == counter) {
                console.info
                        .println("[" + counter + "] " + entry.dateTime.toString(DateTimeFormat.shortDateTime())
                                + " " + entry.user + ": " + entry.message);
            }
            if (detail == counter) {
                id = entry.id;
            }
            counter++;
        }
        if (entry.id.equals(id)) {
            console.info.println("     " + entry.message);
        }

        if (counter > max) {
            break;
        }
    }
}