Example usage for java.text DateFormat SHORT

List of usage examples for java.text DateFormat SHORT

Introduction

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

Prototype

int SHORT

To view the source code for java.text DateFormat SHORT.

Click Source Link

Document

Constant for short style pattern.

Usage

From source file:de.innovationgate.wga.server.api.WGA.java

/**
 * Returns an OpenWGA date format/*from  w w w .  j a v  a  2 s .c  o  m*/
 * @param pattern The date format pattern
 * @param locale A locale to use for locale-dependent date parts. Specify null to let the current WebTML context choose the locale.
 * @throws WGException
 */
public DateFormat getDateFormat(String pattern, Locale locale) throws WGException {

    // Select language for language dependent date formats
    if (locale == null) {
        locale = chooseLocale(locale);
    }

    // Language Fallback(s)

    if (WGUtils.isEmpty(pattern)) {
        return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale);
    }

    // For default patterns
    String lcPattern = pattern.toLowerCase();
    if (lcPattern.endsWith("date") || lcPattern.endsWith("time")) {
        int patternLength;
        if (lcPattern.startsWith("short")) {
            patternLength = DateFormat.SHORT;
        } else if (lcPattern.startsWith("medium")) {
            patternLength = DateFormat.MEDIUM;
        } else if (lcPattern.startsWith("long")) {
            patternLength = DateFormat.LONG;
        } else {
            patternLength = DateFormat.FULL;
        }

        if (lcPattern.endsWith("datetime")) {
            return new TextualDateFormat(locale,
                    DateFormat.getDateTimeInstance(patternLength, patternLength, locale));
        } else if (lcPattern.endsWith("time")) {
            return new TextualDateFormat(locale, DateFormat.getTimeInstance(patternLength, locale));
        } else {
            return new TextualDateFormat(locale, DateFormat.getDateInstance(patternLength, locale));
        }

    } else if (lcPattern.equals("iso8601")) {
        return new ISO8601DateFormat();
    }

    // For custom patterns
    SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, locale);
    dateFormat.setLenient(false);
    return new TextualDateFormat(locale, dateFormat);

}

From source file:org.sakaiproject.lessonbuildertool.tool.beans.SimplePageBean.java

public String addAssignment() {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT,
            new ResourceLoader().getLocale());
    df.setTimeZone(TimeService.getLocalTimeZone());
    if (!itemOk(itemId))
        return "permission-failed";
    if (!canEditPage())
        return "permission-failed";
    if (!checkCsrf())
        return "permission-failed";

    if (selectedAssignment == null) {
        return "failure";
    } else {//w ww  .  j a v a  2  s.c om
        try {
            LessonEntity selectedObject = assignmentEntity.getEntity(selectedAssignment);
            if (selectedObject == null)
                return "failure";

            SimplePageItem i;
            // editing existing item?
            if (itemId != null && itemId != -1) {
                i = findItem(itemId);

                // if no change, don't worry
                LessonEntity existing = assignmentEntity.getEntity(i.getSakaiId());
                String ref = null;
                if (existing != null)
                    ref = existing.getReference();
                // if same quiz, nothing to do
                if ((existing == null) || !ref.equals(selectedAssignment)) {
                    // if access controlled, clear restriction from old assignment and add to new
                    if (i.isPrerequisite()) {
                        if (existing != null) {
                            i.setPrerequisite(false);
                            checkControlGroup(i, false);
                        }
                        // sakaiid and name are used in setting control
                        i.setSakaiId(selectedAssignment);
                        i.setName(selectedObject.getTitle());
                        i.setPrerequisite(true);
                        checkControlGroup(i, true);
                    } else {
                        i.setSakaiId(selectedAssignment);
                        i.setName(selectedObject.getTitle());
                    }
                    // reset assignment-specific stuff
                    // Because we don't update the due date when it changes, this raises more
                    // problems than it fixes. It's also done only for assignments and not tests
                    //   if (selectedObject.getDueDate() != null)
                    //    i.setDescription("(" + messageLocator.getMessage("simplepage.due") + " " + df.format(selectedObject.getDueDate()) + ")");
                    //  else
                    // i.setDescription(null);

                    update(i);
                }
            } else {
                // no, add new item
                i = appendItem(selectedAssignment, selectedObject.getTitle(), SimplePageItem.ASSIGNMENT);
                //if (selectedObject.getDueDate() != null)
                //  i.setDescription("(" + messageLocator.getMessage("simplepage.due") + " " + df.format(selectedObject.getDueDate()) + ")");
                //else
                i.setDescription(null);
                update(i);
            }
            return "success";
        } catch (Exception ex) {
            ex.printStackTrace();
            return "failure";
        } finally {
            selectedAssignment = null;
        }
    }
}

From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java

/**
 * Display a dialog containing the device ID, the device name and the "last seen" information.<>
 * This dialog allow to delete the corresponding device (see {@link #displayDeviceDeletionDialog(DeviceInfo)})
 *
 * @param aDeviceInfo the device information
 *//*from w w  w .j a  v a  2s .  co m*/
private void displayDeviceDetailsDialog(DeviceInfo aDeviceInfo) {
    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
            getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View layout = inflater.inflate(R.layout.devices_details_settings, null);

    if (null != aDeviceInfo) {
        //device ID
        TextView textView = layout.findViewById(R.id.device_id);
        textView.setText(aDeviceInfo.device_id);

        // device name
        textView = layout.findViewById(R.id.device_name);
        String displayName = (TextUtils.isEmpty(aDeviceInfo.display_name)) ? LABEL_UNAVAILABLE_DATA
                : aDeviceInfo.display_name;
        textView.setText(displayName);

        // last seen info
        textView = layout.findViewById(R.id.device_last_seen);
        if (!TextUtils.isEmpty(aDeviceInfo.last_seen_ip)) {
            String lastSeenIp = aDeviceInfo.last_seen_ip;
            String lastSeenTime = LABEL_UNAVAILABLE_DATA;

            if (null != getActivity()) {
                SimpleDateFormat dateFormatTime = new SimpleDateFormat(
                        getString(R.string.devices_details_time_format));
                String time = dateFormatTime.format(new Date(aDeviceInfo.last_seen_ts));

                DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
                lastSeenTime = dateFormat.format(new Date(aDeviceInfo.last_seen_ts)) + ", " + time;
            }
            String lastSeenInfo = this.getString(R.string.devices_details_last_seen_format, lastSeenIp,
                    lastSeenTime);
            textView.setText(lastSeenInfo);
        } else {
            // hide last time seen section
            layout.findViewById(R.id.device_last_seen_title).setVisibility(View.GONE);
            textView.setVisibility(View.GONE);
        }

        // title & icon
        builder.setTitle(R.string.devices_details_dialog_title);
        builder.setIcon(android.R.drawable.ic_dialog_info);
        builder.setView(layout);

        final DeviceInfo fDeviceInfo = aDeviceInfo;

        builder.setPositiveButton(R.string.rename, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                displayDeviceRenameDialog(fDeviceInfo);
            }
        });

        // disable the deletion for our own device
        if (!TextUtils.equals(mSession.getCrypto().getMyDevice().deviceId, fDeviceInfo.device_id)) {
            builder.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    displayDeviceDeletionDialog(fDeviceInfo);
                }
            });
        }

        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
                    dialog.cancel();
                    return true;
                }
                return false;
            }
        });

        builder.create().show();
    } else {
        Log.e(LOG_TAG, "## displayDeviceDetailsDialog(): sanity check failure");
        if (null != getActivity())
            CommonActivityUtils.displayToast(getActivity().getApplicationContext(),
                    "DeviceDetailsDialog cannot be displayed.\nBad input parameters.");
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

private void showThreadPreviewDialog(final int position) {
    final List<PresentationItemModel> items = new ArrayList<>();
    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);/*from ww w . j  av  a 2s  .  c o m*/
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    tmpDlg.show();
    Runnable next = new Runnable() {
        @Override
        public void run() {
            final int dlgWidth = tmpV.getWidth();
            tmpDlg.hide();
            tmpDlg.cancel();
            final Dialog dialog = new Dialog(activity);

            if (presentationModel.source != null && presentationModel.source.threads != null
                    && presentationModel.source.threads.length > position
                    && presentationModel.source.threads[position].posts != null
                    && presentationModel.source.threads[position].posts.length > 0) {

                final String threadNumber = presentationModel.source.threads[position].posts[0].number;

                ClickableURLSpan.URLSpanClickListener spanClickListener = new ClickableURLSpan.URLSpanClickListener() {
                    @Override
                    public void onClick(View v, ClickableURLSpan span, String url, String referer) {
                        if (url.startsWith("#")) {
                            try {
                                UrlPageModel threadPageModel = new UrlPageModel();
                                threadPageModel.chanName = chan.getChanName();
                                threadPageModel.type = UrlPageModel.TYPE_THREADPAGE;
                                threadPageModel.boardName = tabModel.pageModel.boardName;
                                threadPageModel.threadNumber = threadNumber;
                                url = chan.buildUrl(threadPageModel) + url;
                                dialog.dismiss();
                                UrlHandler.open(chan.fixRelativeUrl(url), activity);
                            } catch (Exception e) {
                                Logger.e(TAG, e);
                            }
                        } else {
                            dialog.dismiss();
                            UrlHandler.open(chan.fixRelativeUrl(url), activity);
                        }
                    }
                };

                AndroidDateFormat.initPattern();
                String datePattern = AndroidDateFormat.getPattern();
                DateFormat dateFormat = datePattern == null
                        ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                        : new SimpleDateFormat(datePattern, Locale.US);
                dateFormat.setTimeZone(settings.isLocalTime() ? TimeZone.getDefault()
                        : TimeZone.getTimeZone(presentationModel.source.boardModel.timeZoneId));

                int postsCount = presentationModel.source.threads[position].postsCount;
                boolean showIndex = presentationModel.source.threads[position].posts.length <= postsCount;
                int curPostIndex = postsCount - presentationModel.source.threads[position].posts.length + 1;

                boolean openSpoilers = settings.openSpoilers();

                for (int i = 0; i < presentationModel.source.threads[position].posts.length; ++i) {
                    PresentationItemModel model = new PresentationItemModel(
                            presentationModel.source.threads[position].posts[i], chan.getChanName(),
                            presentationModel.source.pageModel.boardName,
                            presentationModel.source.pageModel.threadNumber, dateFormat, spanClickListener,
                            imageGetter, ThemeUtils.ThemeColors.getInstance(activity.getTheme()), openSpoilers,
                            floatingModels, null);
                    model.buildSpannedHeader(showIndex ? (i == 0 ? 1 : ++curPostIndex) : -1,
                            presentationModel.source.boardModel.bumpLimit,
                            presentationModel.source.boardModel.defaultUserName, null, false);
                    items.add(model);
                }
            } else {
                items.add(presentationModel.presentationList.get(position));
            }
            ListView dlgList = new ListView(activity);
            dlgList.setAdapter(new ArrayAdapter<PresentationItemModel>(activity, 0, items) {
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    View view = adapter.getView(position, convertView, parent, dlgWidth, getItem(position));
                    view.setBackgroundColor(bgColor);
                    return view;
                }
            });
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(dlgList);
            dialog.show();
            dialogs.add(dialog);
        }
    };
    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}

From source file:org.hoteia.qalingo.core.web.mvc.factory.ViewBeanFactory.java

protected String buildShortFormatDate(RequestData requestData, Date date) throws Exception {
    DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.SHORT, DateFormat.SHORT);
    return dateFormat.format(date);
}

From source file:org.sakaiproject.calendar.impl.BaseCalendarService.java

/**
 * Gets the standard date string from the time parameter
 */// w ww .  jav  a  2 s . c o m
protected String getDateFromTime(Time time) {
    TimeBreakdown timeBreakdown = time.breakdownLocal();
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, rb.getLocale());
    return dateFormat.format(new Date(time.getTime()));

}

From source file:net.spfbl.http.ServerHTTP.java

private static String getControlPanel(Locale locale, Query query, long time) {
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(time);//  www  .j a  v  a 2  s  . c o  m
    StringBuilder builder = new StringBuilder();
    //        builder.append("<!DOCTYPE html>\n");
    builder.append("<html lang=\"");
    builder.append(locale.getLanguage());
    builder.append("\">\n");
    builder.append("  <head>\n");
    builder.append("    <meta charset=\"UTF-8\">\n");
    if (locale.getLanguage().toLowerCase().equals("pt")) {
        builder.append("    <title>Painel de controle do SPFBL</title>\n");
    } else {
        builder.append("    <title>SPFBL control panel</title>\n");
    }
    // Styled page.
    builder.append("    <style type=\"text/css\">\n");
    builder.append("      body {");
    builder.append("        background: #b4b9d2;\n");
    builder.append("      }\n");
    builder.append("      .button {\n");
    builder.append("          background-color: #4CAF50;\n");
    builder.append("          border: none;\n");
    builder.append("          color: white;\n");
    builder.append("          padding: 16px 32px;\n");
    builder.append("          text-align: center;\n");
    builder.append("          text-decoration: none;\n");
    builder.append("          display: inline-block;\n");
    builder.append("          font-size: 16px;\n");
    builder.append("          margin: 4px 2px;\n");
    builder.append("          -webkit-transition-duration: 0.4s;\n");
    builder.append("          transition-duration: 0.4s;\n");
    builder.append("          cursor: pointer;\n");
    builder.append("      }\n");
    builder.append("      .white {\n");
    builder.append("          background-color: white; \n");
    builder.append("          color: black; \n");
    builder.append("          border: 2px solid #4CAF50;\n");
    builder.append("          font-weight: bold;\n");
    builder.append("      }\n");
    builder.append("      .white:hover {\n");
    builder.append("          background-color: #4CAF50;\n");
    builder.append("          color: white;\n");
    builder.append("      }\n");
    builder.append("      .block {\n");
    builder.append("          background-color: white; \n");
    builder.append("          color: black; \n");
    builder.append("          border: 2px solid #f44336;\n");
    builder.append("          font-weight: bold;\n");
    builder.append("      }\n");
    builder.append("      .block:hover {\n");
    builder.append("          background-color: #f44336;\n");
    builder.append("          color: white;\n");
    builder.append("      }\n");
    builder.append("      .recipient {\n");
    builder.append("          background-color: white; \n");
    builder.append("          color: black; \n");
    builder.append("          border: 2px solid #555555;\n");
    builder.append("          font-weight: bold;\n");
    builder.append("      }\n");
    builder.append("      .recipient:hover {\n");
    builder.append("          background-color: #555555;\n");
    builder.append("          color: white;\n");
    builder.append("      }\n");
    builder.append("    </style>\n");
    builder.append("  </head>\n");
    // Body.
    builder.append("  <body>\n");
    if (locale.getLanguage().toLowerCase().equals("pt")) {
        builder.append("    <b>Recepo:</b> ");
    } else {
        builder.append("    <b>Reception:</b> ");
    }
    builder.append(dateFormat.format(calendar.getTime()));
    builder.append("<br>\n");
    String sender = query.getSenderSimplified(false, false);
    if (sender == null) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <b>Remetente:</b> MAILER-DAEMON");
        } else {
            builder.append("    <b>Sender:</b> MAILER-DAEMON");
        }
    } else if (query.getQualifierName().equals("PASS")) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <b>Remetente autntico:</b> ");
        } else {
            builder.append("    <b>Genuine sender:</b> ");
        }
        builder.append(sender);
    } else if (query.getQualifierName().equals("FAIL")) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <b>Remetente falso:</b> ");
        } else {
            builder.append("    <b>False sender:</b> ");
        }
        builder.append(sender);
    } else {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <b>Remetente suspeito:</b> ");
        } else {
            builder.append("    <b>Suspect sender:</b> ");
        }
        builder.append(sender);
    }
    builder.append("<br>\n");
    if (locale.getLanguage().toLowerCase().equals("pt")) {
        builder.append("    <b>Recebe por:</b> ");
    } else {
        builder.append("    <b>Receives for:</b> ");
    }
    String validator = query.getValidator(true);
    Situation situationWhite = query.getSenderWhiteSituation();
    Situation situationBlock = query.getSenderBlockSituation();
    try {
        TreeSet<String> mxDomainSet = query.getSenderMXDomainSet();
        if (mxDomainSet.isEmpty()) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("nenhum sistema");
            } else {
                builder.append("no system");
            }
        } else {
            builder.append(mxDomainSet);
        }
    } catch (NameNotFoundException ex) {
        validator = null;
        situationWhite = query.getOriginWhiteSituation();
        situationBlock = query.getOriginBlockSituation();
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("domnio inexistente");
        } else {
            builder.append("non-existent domain");
        }
    } catch (NamingException ex) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("erro ao tentar consultar");
        } else {
            builder.append("error when trying to query");
        }
    }
    builder.append("<br>\n");
    URL unsubscribe = query.getUnsubscribeURL();
    if (unsubscribe == null) {
        builder.append("    <br>\n");
    } else {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("     <b>Cancelar inscrio:</b> ");
        } else {
            builder.append("     <b>List unsubscribe:</b> ");
        }
        builder.append("<a target=\"_blank\" href=\"");
        builder.append(unsubscribe);
        builder.append("\">");
        builder.append(unsubscribe.getHost());
        builder.append(unsubscribe.getPath());
        builder.append("</a><br>\n");
    }
    if (locale.getLanguage().toLowerCase().equals("pt")) {
        builder.append("    <b>Politica vigente:</b> ");
    } else {
        builder.append("    <b>Current policy:</b> ");
    }
    String recipient = query.getRecipient();
    Long trapTime = query.getTrapTime();
    boolean blocked = false;
    if (trapTime == null && situationWhite == Situation.SAME) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("entrega prioritria na mesma situao, exceto malware");
        } else {
            builder.append("priority delivery of ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" in the same situation, except malware");
        }
    } else if (trapTime == null && situationWhite == Situation.AUTHENTIC) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("entrega prioritria de ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" quando comprovadamente autntico, exceto malware");
        } else {
            builder.append("priority delivery of ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" when proven authentic, except malware");
        }
        if (query.isBlock()) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(", porm bloqueado para outras situaes");
            } else {
                builder.append(", however blocked to other situations");
            }
        }
    } else if (trapTime == null && situationWhite == Situation.ZONE) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("entrega prioritria de ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" quando disparado por ");
        } else {
            builder.append("priority delivery of ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" when shot by ");
        }
        builder.append(validator);
        if (query.isBlock()) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(", porm bloqueado para outras situaes");
            } else {
                builder.append(", however blocked to other situations");
            }
        }
    } else if (trapTime == null && situationWhite == Situation.IP) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("entrega prioritria de ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" when shot by IP ");
        } else {
            builder.append("priority delivery of ");
            builder.append(query.getSenderSimplified(false, true));
            builder.append(" when coming from the IP ");
        }
        builder.append(validator);
        if (query.isBlock()) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(", porm bloqueado para outras situaes");
            } else {
                builder.append(", however blocked to other situations");
            }
        }
    } else if (trapTime == null && situationWhite == Situation.ORIGIN) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("entrega prioritria pela mesma origem");
        } else {
            builder.append("priority delivery the same origin");
        }
    } else if (situationBlock == Situation.DOMAIN) {
        blocked = true;
        String domain = query.getSenderSimplified(true, false);
        if (domain == null) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("bloquear na mesma situao");
            } else {
                builder.append("block in the same situation");
            }
        } else {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("bloquear ");
                builder.append(domain);
                builder.append(" em qualquer situao");
            } else {
                builder.append("block ");
                builder.append(domain);
                builder.append(" in any situation");
            }
        }
    } else if (situationBlock == Situation.ALL) {
        blocked = true;
        String domain = query.getOriginDomain(false);
        if (domain == null) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("bloquear na mesma situao");
            } else {
                builder.append("block in the same situation");
            }
        } else {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("bloquear ");
                builder.append(domain);
                builder.append(" em qualquer situao");
            } else {
                builder.append("block ");
                builder.append(domain);
                builder.append(" in any situation");
            }
        }
    } else if (situationBlock == Situation.SAME) {
        blocked = true;
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("bloquear na mesma situao");
        } else {
            builder.append("block in the same situation");
        }
    } else if ((situationBlock == Situation.ZONE || situationBlock == Situation.IP)
            && !query.getQualifierName().equals("PASS")) {
        blocked = true;
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("bloquear ");
            builder.append(query.getSenderDomain(false));
            builder.append(" quando no for autntico");
        } else {
            builder.append("block ");
            builder.append(query.getSenderDomain(false));
            builder.append(" when not authentic");
        }
    } else if (situationBlock == Situation.ORIGIN) {
        blocked = true;
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("bloquear quando disparado pela mesma origem");
        } else {
            builder.append("block when shot by the same source");
        }
    } else if (query.isFail()) {
        blocked = true;
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("rejeitar entrega por falsificao");
        } else {
            builder.append("reject delivery of forgery");
        }
    } else if (trapTime != null) {
        if (System.currentTimeMillis() > trapTime) {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("descartar mensagem por armadilha");
            } else {
                builder.append("discard message by spamtrap");
            }
        } else {
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("rejeitar entrega por destinatrio inexistente");
            } else {
                builder.append("reject delivery by inexistent recipient");
            }
        }
    } else if (query.hasTokenRed() || query.hasClusterRed()) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("marcar como suspeita e entregar, sem considerar o contedo");
        } else {
            builder.append("flag as suspected and deliver, regardless of content");
        }
    } else if (query.isSoftfail() || query.hasYellow()) {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("atrasar entrega na mesma situao, sem considerar o contedo");
        } else {
            builder.append("delay delivery in the same situation, regardless of content");
        }
    } else {
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("aceitar entrega na mesma situao, sem considerar o contedo");
        } else {
            builder.append("accept delivery in the same situation, regardless of content");
        }
    }
    builder.append(".<br>\n");
    builder.append("    <form method=\"POST\">\n");
    if (validator == null) {
        if (situationWhite != Situation.ORIGIN) {
            builder.append(
                    "      <button type=\"submit\" class=\"white\" name=\"POLICY\" value=\"WHITE_ORIGIN\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Entrega prioritria quando for da mesma origem\n");
            } else {
                builder.append("Priority delivery when the same origin\n");
            }
            builder.append("</button>\n");
        }
        if (situationWhite != Situation.NONE || situationBlock != Situation.ALL) {
            if (situationBlock != Situation.ORIGIN) {
                builder.append(
                        "      <button type=\"submit\" class=\"block\" name=\"POLICY\" value=\"BLOCK_ORIGIN\">");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append("Bloquear se for da mesma origem");
                } else {
                    builder.append("Block if the same origin");
                }
                builder.append("</button>\n");
            }
            String domain = query.getOriginDomain(false);
            if (domain != null) {
                builder.append(
                        "      <button type=\"submit\" class=\"block\" name=\"POLICY\" value=\"BLOCK_ALL\">");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append("Bloquear ");
                    builder.append(domain);
                    builder.append(" em qualquer situao");
                } else {
                    builder.append("Block ");
                    builder.append(domain);
                    builder.append(" in any situation");
                }
                builder.append("</button>\n");
            }
        }
    } else if (validator.equals("PASS")) {
        if (situationWhite != Situation.AUTHENTIC) {
            builder.append(
                    "      <button type=\"submit\" class=\"white\" name=\"POLICY\" value=\"WHITE_AUTHENTIC\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Entrega prioritria quando comprovadamente autntico\n");
            } else {
                builder.append("Priority delivery when proven authentic\n");
            }
            builder.append("</button>\n");
        }
    } else if (Subnet.isValidIP(validator)) {
        if (situationWhite != Situation.IP) {
            builder.append("      <button type=\"submit\" class=\"white\" name=\"POLICY\" value=\"WHITE_IP\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Entrega prioritria quando disparado pelo IP ");
            } else {
                builder.append("Priority delivery when shot by IP ");
            }
            builder.append(validator);
            builder.append("</button>\n");
        }
        if (situationBlock != Situation.IP && situationBlock != Situation.DOMAIN) {
            builder.append("      <button type=\"submit\" class=\"block\" name=\"POLICY\" value=\"BLOCK_IP\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Bloquear ");
                builder.append(query.getSenderDomain(false));
                builder.append(" quando no for autntico");
            } else {
                builder.append("Block ");
                builder.append(query.getSenderDomain(false));
                builder.append(" when not authentic");
            }
            builder.append("</button>\n");
        }
    } else if (Domain.isHostname(validator)) {
        if (situationWhite != Situation.ZONE) {
            builder.append(
                    "      <button type=\"submit\" class=\"white\" name=\"POLICY\" value=\"WHITE_ZONE\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Entrega prioritria quando disparado por ");
            } else {
                builder.append("Priority delivery when shot by ");
            }
            builder.append(validator);
            builder.append("</button>\n");
        }
        if (situationBlock != Situation.ZONE && situationBlock != Situation.DOMAIN) {
            builder.append(
                    "      <button type=\"submit\" class=\"block\" name=\"POLICY\" value=\"BLOCK_ZONE\">");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append("Bloquear ");
                builder.append(query.getSenderDomain(false));
                builder.append(" quando no for autntico");
            } else {
                builder.append("Block ");
                builder.append(query.getSenderDomain(false));
                builder.append(" when not authentic");
            }
            builder.append("</button>\n");
        }
    }
    if (situationBlock != Situation.DOMAIN && validator != null) {
        builder.append("      <button type=\"submit\" class=\"block\" name=\"POLICY\" value=\"BLOCK_DOMAIN\">");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("Bloquear ");
            builder.append(query.getSenderSimplified(true, false));
            builder.append(" em qualquer situao");
        } else {
            builder.append("Block ");
            builder.append(query.getSenderSimplified(true, false));
            builder.append(" in any situation");
        }
        builder.append("</button>\n");
    }
    if (!blocked && recipient != null && trapTime != null && query.getUser().isPostmaster()) {
        builder.append(
                "      <button type=\"submit\" class=\"recipient\" name=\"POLICY\" value=\"WHITE_RECIPIENT\">");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("Tornar ");
            builder.append(recipient);
            builder.append(" existente");
        } else {
            builder.append("Make ");
            builder.append(recipient);
            builder.append(" existent");
        }
        builder.append("</button>\n");
    }
    builder.append("    </form>\n");
    builder.append("  </body>\n");
    builder.append("</html>\n");
    return builder.toString();
}

From source file:com.codename1.impl.android.AndroidImplementation.java

/**
 * @inheritDoc/*from w  w w  .jav a2  s  .c  om*/
 */
public L10NManager getLocalizationManager() {
    if (l10n == null) {
        Locale l = Locale.getDefault();
        l10n = new L10NManager(l.getLanguage(), l.getCountry()) {
            public double parseDouble(String localeFormattedDecimal) {
                try {
                    return NumberFormat.getNumberInstance().parse(localeFormattedDecimal).doubleValue();
                } catch (ParseException err) {
                    return Double.parseDouble(localeFormattedDecimal);
                }
            }

            public String format(int number) {
                return NumberFormat.getNumberInstance().format(number);
            }

            public String format(double number) {
                return NumberFormat.getNumberInstance().format(number);
            }

            public String formatCurrency(double currency) {
                return NumberFormat.getCurrencyInstance().format(currency);
            }

            public String formatDateLongStyle(Date d) {
                return DateFormat.getDateInstance(DateFormat.LONG).format(d);
            }

            public String formatDateShortStyle(Date d) {
                return DateFormat.getDateInstance(DateFormat.SHORT).format(d);
            }

            public String formatDateTime(Date d) {
                return DateFormat.getDateTimeInstance().format(d);
            }

            public String formatDateTimeMedium(Date d) {
                DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
                return dd.format(d);
            }

            public String formatDateTimeShort(Date d) {
                DateFormat dd = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
                return dd.format(d);
            }

            public String getCurrencySymbol() {
                return NumberFormat.getInstance().getCurrency().getSymbol();
            }

            public void setLocale(String locale, String language) {
                super.setLocale(locale, language);
                Locale l = new Locale(language, locale);
                Locale.setDefault(l);
            }
        };
    }
    return l10n;
}

From source file:net.spfbl.http.ServerHTTP.java

private static String getControlPanel(Locale locale, User user, Long begin, String filter) {
    StringBuilder builder = new StringBuilder();
    if (begin == null && filter == null) {
        //            builder.append("<!DOCTYPE html>\n");
        builder.append("<html lang=\"");
        builder.append(locale.getLanguage());
        builder.append("\">\n");
        builder.append("  <head>\n");
        builder.append("    <meta charset=\"UTF-8\">\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("    <title>Painel de controle do SPFBL</title>\n");
        } else {//from  w ww.ja v  a  2 s . com
            builder.append("    <title>SPFBL control panel</title>\n");
        }
        // Styled page.
        builder.append("    <style type=\"text/css\">\n");
        builder.append("      body {\n");
        builder.append("        margin:180px 0px 30px 0px;\n");
        builder.append("        background:lightgray;\n");
        builder.append("      }\n");
        builder.append("      iframe {\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:150px;\n");
        builder.append("      }\n");
        builder.append("      .header {\n");
        builder.append("        background-color:lightgray;\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        position:fixed;\n");
        builder.append("        top:0px;\n");
        builder.append("        margin:auto;\n");
        builder.append("        z-index:1;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:180px;\n");
        builder.append("      }\n");
        builder.append("      .bottom {\n");
        builder.append("        background-color:lightgray;\n");
        builder.append("        border-width: 0px 0px 0px 0px;\n");
        builder.append("        position:fixed;\n");
        builder.append("        bottom:0px;\n");
        builder.append("        margin:auto;\n");
        builder.append("        z-index:1;\n");
        builder.append("        width:100%;\n");
        builder.append("        height:30px;\n");
        builder.append("      }\n");
        builder.append("      .button {\n");
        builder.append("          background-color: #4CAF50;\n");
        builder.append("          border: none;\n");
        builder.append("          color: white;\n");
        builder.append("          padding: 16px 32px;\n");
        builder.append("          text-align: center;\n");
        builder.append("          text-decoration: none;\n");
        builder.append("          display: inline-block;\n");
        builder.append("          font-size: 16px;\n");
        builder.append("          margin: 4px 2px;\n");
        builder.append("          -webkit-transition-duration: 0.4s;\n");
        builder.append("          transition-duration: 0.4s;\n");
        builder.append("          cursor: pointer;\n");
        builder.append("      }\n");
        builder.append("      .sender {\n");
        builder.append("          background-color: white; \n");
        builder.append("          color: black; \n");
        builder.append("          border: 2px solid #008CBA;\n");
        builder.append("          width: 100%;\n");
        builder.append("          word-wrap: break-word;\n");
        builder.append("      }\n");
        builder.append("      .sender:hover {\n");
        builder.append("          background-color: #008CBA;\n");
        builder.append("          color: white;\n");
        builder.append("      }\n");
        builder.append("      .highlight {\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("        color:black;\n");
        builder.append("        border-top: 1px solid #22262e;\n");
        builder.append("        border-bottom: 1px solid #22262e;\n");
        builder.append("      }\n");
        builder.append("      .highlight:nth-child(odd) td {\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("      }\n");
        builder.append("      .click {\n");
        builder.append("        cursor:pointer;\n");
        builder.append("        cursor:hand;\n");
        builder.append("      }\n");
        builder.append("      table {\n");
        builder.append("        background: white;\n");
        builder.append("        table-layout:fixed;\n");
        builder.append("        border-collapse: collapse;\n");
        builder.append("        word-wrap:break-word;\n");
        builder.append("        border-radius:3px;\n");
        builder.append("        border-collapse: collapse;\n");
        builder.append("        margin: auto;\n");
        builder.append("        padding:2px;\n");
        builder.append("        width: 100%;\n");
        builder.append("        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);\n");
        builder.append("        animation: float 5s infinite;\n");
        builder.append("      }\n");
        builder.append("      th {\n");
        builder.append("        color:#FFFFFF;;\n");
        builder.append("        background:#1b1e24;\n");
        builder.append("        border-bottom:4px solid #9ea7af;\n");
        builder.append("        border-right: 0px;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        font-weight: bold;\n");
        builder.append("        padding:4px;\n");
        builder.append("        text-align:left;\n");
        builder.append("        text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);\n");
        builder.append("        vertical-align:middle;\n");
        builder.append("        height:30px;\n");
        builder.append("      }\n");
        builder.append("      tr {\n");
        builder.append("        border-top: 1px solid #C1C3D1;\n");
        builder.append("        border-bottom-: 1px solid #C1C3D1;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        font-weight:normal;\n");
        builder.append("        text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);\n");
        builder.append("      }\n");
        builder.append("      tr:nth-child(odd) td {\n");
        builder.append("        background:#EBEBEB;\n");
        builder.append("      }\n");
        builder.append("      td {\n");
        builder.append("        padding:2px;\n");
        builder.append("        vertical-align:middle;\n");
        builder.append("        font-size:16px;\n");
        builder.append("        text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);\n");
        builder.append("        border-right: 1px solid #C1C3D1;\n");
        builder.append("      }\n");
        builder.append("      input[type=text], select {\n");
        builder.append("        width: 400px;\n");
        builder.append("        padding: 0px 4px;\n");
        builder.append("        margin: 1px 0;\n");
        builder.append("        display: inline-block;\n");
        builder.append("        background: #b4b9d2;\n");
        builder.append("        border: 1px solid #ccc;\n");
        builder.append("        border-radius: 4px;\n");
        builder.append("        box-sizing: border-box;\n");
        builder.append("      }\n");
        builder.append("    </style>\n");
        // JavaScript functions.
        TreeMap<Long, Query> queryMap = user.getQueryMap(null, null);
        builder.append(
                "    <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script>\n");
        builder.append("    <script type=\"text/javascript\">\n");
        builder.append("      window.onbeforeunload = function () {\n");
        builder.append("        document.getElementById('filterField').value = '';\n");
        builder.append("        window.scrollTo(0, 0);\n");
        builder.append("      }\n");
        builder.append("      var last = ");
        if (queryMap.isEmpty()) {
            builder.append(0);
        } else {
            builder.append(queryMap.lastKey());
        }
        builder.append(";\n");
        builder.append("      var filterText = '';\n");
        builder.append("      function view(query) {\n");
        builder.append("        if (query == undefined || query == 0) {\n");
        builder.append("          var viewer = document.getElementById('viewer');\n");
        builder.append("          viewer.src = 'about:blank';\n");
        builder.append("          last = 0;\n");
        builder.append("        } else if (last != query) {\n");
        builder.append("          var viewer = document.getElementById('viewer');\n");
        builder.append("          viewer.addEventListener('load', function() {\n");
        builder.append("            if (document.getElementById(last)) {\n");
        builder.append("              document.getElementById(last).className = 'tr';\n");
        builder.append("              document.getElementById(last).className = 'click';\n");
        builder.append("            }\n");
        builder.append("            document.getElementById(query).className = 'highlight';\n");
        builder.append("            last = query;\n");
        builder.append("          });\n");
        builder.append("          viewer.src = '");
        builder.append(Core.getURL());
        builder.append("' + query;\n");
        builder.append("        }\n");
        builder.append("      }\n");
        builder.append("      function more(query) {\n");
        builder.append("        var rowMore = document.getElementById('rowMore');\n");
        builder.append("        rowMore.onclick = '';\n");
        builder.append("        rowMore.className = 'tr';\n");
        builder.append("        var columnMore = document.getElementById('columnMore');\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("        columnMore.innerHTML = 'carregando mais registros';\n");
        } else {
            builder.append("        columnMore.innerHTML = 'loading more records';\n");
        }
        builder.append("        $.post(\n");
        builder.append("          '");
        builder.append(Core.getURL());
        builder.append(user.getEmail());
        builder.append("',\n");
        builder.append("          {filter:filterText,begin:query},\n");
        builder.append("          function(data, status) {\n");
        builder.append("            if (status == 'success') {\n");
        builder.append("              rowMore.parentNode.removeChild(rowMore);\n");
        builder.append("              $('#tableBody').append(data);\n");
        builder.append("            } else {\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "              alert('Houve uma falha de sistema ao tentar realizar esta operao.');\n");
        } else {
            builder.append(
                    "              alert('There was a system crash while trying to perform this operation.');\n");
        }
        builder.append("            }\n");
        builder.append("          }\n");
        builder.append("        );\n");
        builder.append("      }\n");
        builder.append("      function refresh() {\n");
        builder.append("        filterText = document.getElementById('filterField').value;\n");
        builder.append("        $.post(\n");
        builder.append("          '");
        builder.append(Core.getURL());
        builder.append(user.getEmail());
        builder.append("',\n");
        builder.append("          {filter:filterText},\n");
        builder.append("          function(data, status) {\n");
        builder.append("            if (status == 'success') {\n");
        builder.append("              $('#tableBody').html(data);\n");
        builder.append("              view($('#tableBody tr').attr('id'));\n");
        builder.append("            } else {\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "              alert('Houve uma falha de sistema ao tentar realizar esta operao.');\n");
        } else {
            builder.append(
                    "              alert('There was a system crash while trying to perform this operation.');\n");
        }
        builder.append("            }\n");
        builder.append("          }\n");
        builder.append("        );\n");
        builder.append("      }\n");
        builder.append("    </script>\n");
        builder.append("  </head>\n");
        // Body.
        builder.append("  <body>\n");
        builder.append("    <div class=\"header\">\n");
        if (queryMap.isEmpty()) {
            builder.append("      <iframe id=\"viewer\" src=\"about:blank\"></iframe>\n");
        } else {
            builder.append("      <iframe id=\"viewer\" src=\"");
            builder.append(Core.getURL());
            builder.append(queryMap.lastKey());
            builder.append("\"></iframe>\n");
        }
        // Construo da tabela de consultas.
        builder.append("      <table>\n");
        builder.append("        <thead>\n");
        builder.append("          <tr>\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append("            <th style=\"width:120px;\">Recepo</th>\n");
            builder.append("            <th>Origem</th>\n");
            builder.append("            <th>Remetente</th>\n");
            builder.append("            <th>Contedo</th>\n");
            builder.append("            <th>Entrega</th>\n");
        } else {
            builder.append("            <th style=\"width:160px;\">Reception</th>\n");
            builder.append("            <th style=\"width:auto;\">Source</th>\n");
            builder.append("            <th style=\"width:auto;\">Sender</th>\n");
            builder.append("            <th style=\"width:auto;\">Content</th>\n");
            builder.append("            <th style=\"width:auto;\">Delivery</th>\n");
        }
        builder.append("          </tr>\n");
        builder.append("        </thead>\n");
        builder.append("      </table>\n");
        builder.append("    </div>\n");
        if (queryMap.isEmpty()) {
            builder.append("    <table>\n");
            builder.append("      <tbody>\n");
            builder.append("        <tr>\n");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(
                        "          <td colspan=\"5\" align=\"center\">nenhum registro encontrado</td>\n");
            } else {
                builder.append("          <td colspan=\"5\" align=\"center\">no records found</td>\n");
            }
            builder.append("        </tr>\n");
            builder.append("      </tbody>\n");
            builder.append("    </table>\n");
        } else {
            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
            GregorianCalendar calendar = new GregorianCalendar();
            Long nextQuery = null;
            while (queryMap.size() > User.QUERY_MAX_ROWS) {
                nextQuery = queryMap.pollFirstEntry().getKey();
            }
            builder.append("    <table>\n");
            builder.append("      <tbody id=\"tableBody\">\n");
            for (Long time : queryMap.descendingKeySet()) {
                User.Query query = queryMap.get(time);
                boolean highlight = time.equals(queryMap.lastKey());
                buildQueryRow(locale, builder, dateFormat, calendar, time, query, highlight);
            }
            if (nextQuery == null) {
                builder.append("      <tr>\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "        <td colspan=\"5\" align=\"center\">no foram encontrados outros registros</td>\n");
                } else {
                    builder.append("        <td colspan=\"5\" align=\"center\">no more records found</td>\n");
                }
                builder.append("      </tr>\n");
            } else {
                builder.append("        <tr id=\"rowMore\" class=\"click\" onclick=\"more('");
                builder.append(nextQuery);
                builder.append("')\">\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">clique para ver mais registros</td>\n");
                } else {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">click to see more records</td>\n");
                }
                builder.append("        </tr>\n");
            }
            builder.append("      </tbody>\n");
            builder.append("    </table>\n");
        }
        builder.append("    <div class=\"bottom\">\n");
        builder.append("      <table>\n");
        builder.append("        <tr>\n");
        if (locale.getLanguage().toLowerCase().equals("pt")) {
            builder.append(
                    "          <th>Pesquisar <input type=\"text\" id=\"filterField\" name=\"filterField\" onkeydown=\"if (event.keyCode == 13) refresh();\" autofocus></th>\n");
        } else {
            builder.append(
                    "          <th>Search <input type=\"text\" id=\"filterField\" name=\"filterField\" onkeydown=\"if (event.keyCode == 13) refresh();\" autofocus></th>\n");
        }
        builder.append("          <th style=\"text-align:right;\"><small>");
        builder.append(
                "Powered by <a target=\"_blank\" href=\"http://spfbl.net/\" style=\"color: #b4b9d2;\">SPFBL.net</a></small>");
        builder.append("</th>\n");
        builder.append("        </tr>\n");
        builder.append("      <table>\n");
        builder.append("    </div>\n");
        builder.append("  </body>\n");
        builder.append("</html>\n");
    } else {
        TreeMap<Long, Query> queryMap = user.getQueryMap(begin, filter);
        if (queryMap.isEmpty()) {
            builder.append("        <tr>\n");
            if (locale.getLanguage().toLowerCase().equals("pt")) {
                builder.append(
                        "          <td colspan=\"5\" align=\"center\">nenhum registro encontrado</td>\n");
            } else {
                builder.append("          <td colspan=\"5\" align=\"center\">no records found</td>\n");
            }
            builder.append("        </tr>\n");
        } else {
            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
            GregorianCalendar calendar = new GregorianCalendar();
            Long nextQuery = null;
            while (queryMap.size() > User.QUERY_MAX_ROWS) {
                nextQuery = queryMap.pollFirstEntry().getKey();
            }
            for (Long time : queryMap.descendingKeySet()) {
                User.Query query = queryMap.get(time);
                buildQueryRow(locale, builder, dateFormat, calendar, time, query, false);
            }
            if (nextQuery == null) {
                builder.append("        <tr>\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td colspan=\"5\" align=\"center\">no foram encontrados outros registros</td>\n");
                } else {
                    builder.append("          <td colspan=\"5\" align=\"center\">no more records found</td>\n");
                }
                builder.append("        </tr>\n");
            } else {
                builder.append("        <tr id=\"rowMore\" class=\"click\" onclick=\"more('");
                builder.append(nextQuery);
                builder.append("')\">\n");
                if (locale.getLanguage().toLowerCase().equals("pt")) {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">clique para ver mais registros</td>\n");
                } else {
                    builder.append(
                            "          <td id=\"columnMore\" colspan=\"5\" align=\"center\">click to see more records</td>\n");
                }
                builder.append("        </tr>\n");
            }
        }
    }
    return builder.toString();
}