Example usage for java.text DateFormat getCalendar

List of usage examples for java.text DateFormat getCalendar

Introduction

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

Prototype

public Calendar getCalendar() 

Source Link

Document

Gets the calendar associated with this date/time formatter.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getDateTimeInstance();

    String s = dateFormat.format(new Date());
    System.out.println(dateFormat.getCalendar());

}

From source file:com.icesoft.tutorial.TimeZoneBean.java

public static String formatCurrentTime(DateFormat dateFormat) {
    Calendar cal = dateFormat.getCalendar();
    cal.setTimeInMillis(System.currentTimeMillis());
    return dateFormat.format(cal.getTime());
}

From source file:org.mule.modules.clarizen.api.ClarizenDateConverter.java

/**
 * Parse a String into a <code>Calendar</code> object
 * using the specified <code>DateFormat</code>.
 *
 * @param sourceType The type of the value being converted
 * @param targetType The type to convert the value to
 * @param value The String date value./*from   w w w.  ja v a2 s  .co  m*/
 * @param format The DateFormat to parse the String value.
 *
 * @return The converted Calendar object.
 * @throws ConversionException if the String cannot be converted.
 */
@SuppressWarnings("rawtypes")
private Calendar parse(Class sourceType, Class targetType, String value, DateFormat format) {
    format.setLenient(false);
    ParsePosition pos = new ParsePosition(0);
    Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar)
    if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) {
        String msg = "Error converting '" + classToString(sourceType) + "' to '" + classToString(targetType)
                + "'";
        if (format instanceof SimpleDateFormat) {
            msg += " using pattern '" + ((SimpleDateFormat) format).toPattern() + "'";
        }
        throw new ConversionException(msg);
    }
    Calendar calendar = format.getCalendar();
    return calendar;
}

From source file:com.examples.with.different.packagename.testcarver.DateTimeConverter.java

/**
 * Parse a String into a <code>Calendar</code> object
 * using the specified <code>DateFormat</code>.
 *
 * @param sourceType The type of the value being converted
 * @param targetType The type to convert the value to
 * @param value The String date value./*from  w ww.  j a v  a  2s  . c o m*/
 * @param format The DateFormat to parse the String value.
 *
 * @return The converted Calendar object.
 * @throws ConversionException if the String cannot be converted.
 */
private Calendar parse(Class sourceType, Class targetType, String value, DateFormat format) {
    logFormat("Parsing", format);
    format.setLenient(false);
    ParsePosition pos = new ParsePosition(0);
    Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar)
    if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) {
        String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'";
        if (format instanceof SimpleDateFormat) {
            msg += " using pattern '" + ((SimpleDateFormat) format).toPattern() + "'";
        }
        throw new ConversionException(msg);
    }
    Calendar calendar = format.getCalendar();
    return calendar;
}

From source file:javadz.beanutils.converters.DateTimeConverter.java

/**
 * Parse a String into a <code>Calendar</code> object
 * using the specified <code>DateFormat</code>.
 *
 * @param sourceType The type of the value being converted
 * @param targetType The type to convert the value to
 * @param value The String date value.//from   www . jav a  2s  .com
 * @param format The DateFormat to parse the String value.
 *
 * @return The converted Calendar object.
 * @throws ConversionException if the String cannot be converted.
 */
private Calendar parse(Class sourceType, Class targetType, String value, DateFormat format) {
    logFormat("Parsing", format);
    format.setLenient(false);
    ParsePosition pos = new ParsePosition(0);
    Date parsedDate = format.parse(value, pos); // ignore the result (use the Calendar)
    if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || parsedDate == null) {
        String msg = "Error converting '" + toString(sourceType) + "' to '" + toString(targetType) + "'";
        if (format instanceof SimpleDateFormat) {
            msg += " using pattern '" + ((SimpleDateFormat) format).toPattern() + "'";
        }
        if (log().isDebugEnabled()) {
            log().debug("    " + msg);
        }
        throw new ConversionException(msg);
    }
    Calendar calendar = format.getCalendar();
    return calendar;
}

From source file:de.tuttas.servlets.DokuServlet.java

private Document createVertretungsliste(Date parsedFrom, Date parsedTo, OutputStream out)
        throws DocumentException, BadElementException, IOException {
    Document document = new Document();
    Log.d("create Vertretungsliste von " + parsedFrom.toString() + " bis" + parsedTo.toString());
    GregorianCalendar cf = (GregorianCalendar) GregorianCalendar.getInstance();
    cf.setTime(parsedFrom);//from  w w  w .  ja va  2  s . co m
    GregorianCalendar ct = (GregorianCalendar) GregorianCalendar.getInstance();
    ct.setTime(parsedTo);
    /* Basic PDF Creation inside servlet */
    PdfWriter writer = PdfWriter.getInstance(document, out);
    StringBuilder htmlString = new StringBuilder();
    String kopf = "";
    kopf += ("<table border='1' align='center' width='100%'>");
    kopf += ("<tr>");
    kopf += ("<td rowspan=\"3\" width='150px'></td>");
    kopf += ("<td align='center'><h2>Multi Media Berufsbildende Schulen Hannover</h2></td>");

    kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Vertretungsliste</b></td>");
    kopf += ("</tr>");
    kopf += ("<tr>");
    kopf += ("<td  align='center' rowspan=\"2\"><h3>von " + toReadableDate(cf) + " bis " + toReadableDate(ct)
            + "</h3></td>");
    kopf += ("<td  style=\"font-size: 11;padding:4px;height:30px;\">Verantwortlicher: BO&nbsp;</td>");
    kopf += ("<td  style=\"font-size: 11;padding:4px;\">geprft</td>");
    kopf += ("</tr>");
    kopf += ("<tr>");
    DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
    Calendar c = df.getCalendar();
    c.setTimeInMillis(System.currentTimeMillis());
    String dat = c.get(Calendar.DAY_OF_MONTH) + "." + (c.get(Calendar.MONTH) + 1) + "." + c.get(Calendar.YEAR);
    kopf += ("<td  style=\"font-size: 11;\">Ausdruck am: " + dat + "</td>");
    kopf += ("<td  style=\"font-size: 11;\">Datum</td>");
    kopf += ("</tr>");
    kopf += ("</table>");
    kopf += ("<p>&nbsp;</p>");
    htmlString.append(kopf);
    document.open();

    Query qb = em.createNamedQuery("findVertretungbyDate");
    qb.setParameter("paramFromDate", parsedFrom);
    qb.setParameter("paramToDate", parsedTo);
    List<Vertretung> vl = qb.getResultList();
    Log.d("Result Liste = " + vl);

    for (Vertretung v : vl) {
        htmlString.append("<h3>Absenz von " + v.getAbsenzVon() + " am " + toReadableFromat(v.getAbsenzAm())
                + " eingereicht von " + v.getEingereichtVon() + " am " + toReadableFromat(v.getEingereichtAm())
                + "</h3>");
        htmlString.append("<h4>" + v.getKommentar() + "</h4>");
        htmlString.append("<p> </p>");
        htmlString.append("<table border='0.5' align='center' width='100%'>");
        htmlString.append("<tr>");
        htmlString.append(
                "<td width='10%' style=\"padding:4px;\">Stunde</td><td width='15%' style=\"padding:4px;\">Klasse</td><td width='15%' style=\"padding:4px;\">Aktion</td><td width='10%' style=\"padding:4px;\">Vertreter</td><td style=\"padding:4px;\">Kommentar</td>");
        htmlString.append("</tr>");
        JSONParser jsonParser = new JSONParser();
        try {
            JSONArray ja = (JSONArray) jsonParser.parse(v.getJsonString());

            for (int i = 0; i < ja.size(); i++) {
                JSONObject jo = (JSONObject) ja.get(i);
                htmlString.append("<tr>");
                htmlString.append(
                        "<td style=\"font-size: 11;padding:4px;\" width='10%'>" + jo.get("stunde") + "</td>");
                htmlString.append(
                        "<td style=\"font-size: 11;padding:4px;\" width='15%'>" + jo.get("Klasse") + "</td>");
                htmlString.append(
                        "<td style=\"font-size: 11;padding:4px;\" width='15%'>" + jo.get("Aktion") + "</td>");
                htmlString.append("<td style=\"font-size: 11;padding:4px;\" width='10%'>" + jo.get("Vertreter")
                        + "</td>");
                htmlString.append("<td style=\"font-size: 11;padding:4px;\">" + jo.get("Kommentar") + "</td>");
                htmlString.append("</tr>");
            }

        } catch (org.json.simple.parser.ParseException ex) {
            ex.printStackTrace();
            Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        htmlString.append("</table>");
        htmlString.append("<p></p>");
    }

    //document.add(new Paragraph("Tutorial to Generate PDF using Servlet"));
    InputStream is = new ByteArrayInputStream(htmlString.toString().getBytes());
    // Bild einfgen
    String url = "http://www.mmbbs.de/fileadmin/template/mmbbs/gfx/mmbbs_logo_druck.gif";
    Image image = Image.getInstance(url);
    image.setAbsolutePosition(45f, 720f);
    image.scalePercent(50f);
    document.add(image);
    XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
    document.close();
    return document;
}

From source file:de.tuttas.servlets.DokuServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  www.j  a  v a 2 s  .  co  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String auth = request.getParameter("auth_token");
    String service = request.getParameter("service_key");
    Log.d("auth_token=" + auth);
    if (request.getParameter("cmd") == null || request.getParameter("idklasse") == null
            || request.getParameter("from") == null) {
        Log.d("Info zeigen");
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Doku Servlet Usage</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Doku Servlet @ " + request.getContextPath() + "</h1>");
            out.println(
                    "<a href='?cmd=Verlauf&idklasse=3608&from=2015-09-08&debug=" + Config.getInstance().debug
                            + "' target='_pdf'>Usage: ?cmd=verlauf&idklasse=3608&from=2015-09-08</a>");
            out.println("</body>");
            out.println("</html>");
        }
    } else {
        if (Config.getInstance().debug
                || service != null && auth != null && Authenticator.getInstance().isAuthTokenValid(auth)) {
            Log.d("ID Klasse = " + request.getParameter("idklasse"));
            Klasse kl = em.find(Klasse.class, Integer.parseInt(request.getParameter("idklasse")));
            String cmd = request.getParameter("cmd");
            String type = request.getParameter("type");
            String sidSchuljahr = request.getParameter("idSchuljahr");
            int idSchuljahr = -1;
            if (sidSchuljahr != null) {
                try {
                    idSchuljahr = Integer.parseInt(sidSchuljahr);
                } catch (NumberFormatException nux) {

                }
            }
            String filter1 = request.getParameter("dokufilter1");
            String filter2 = request.getParameter("dokufilter2");
            int anwFilter1 = 0;
            int anwFilter2 = 0;
            if (request.getParameter("anwfilter1") != null) {
                anwFilter1 = Integer.parseInt(request.getParameter("anwfilter1"));
            }
            if (request.getParameter("anwfilter2") != null) {
                anwFilter2 = Integer.parseInt(request.getParameter("anwfilter2"));
            }
            Authenticator a = Authenticator.getInstance();
            String me = a.getUser(auth);
            Log.d("Verlauf Filter1=" + filter1 + " Verlauf Filter2=" + filter2 + " me=" + me);
            Log.d("Anwesenheitsfilter 1 = " + anwFilter1 + " Filter2=" + anwFilter2);
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            Date parsedFrom = null;
            try {
                parsedFrom = (Date) dateFormat.parse(request.getParameter("from"));
            } catch (ParseException ex) {
                Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
            Date parsedTo = null;
            if (request.getParameter("to") == null) {
                parsedTo = new java.sql.Date(System.currentTimeMillis());
            } else {
                try {
                    parsedTo = (Date) dateFormat.parse(request.getParameter("to"));
                } catch (ParseException ex) {
                    Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            Log.d("setze To auf " + new java.sql.Date(parsedTo.getTime()));
            Log.d("type=" + type + " cmd=" + cmd + " Klasse=" + kl.getKNAME());
            if (type.compareTo("csv") == 0) {

                MyTableDataModel myModel = null;
                if (cmd.compareTo("Betriebe") == 0) {
                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = cmd + "_" + kl.getKNAME() + "_"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);

                    myModel = getModelBetriebsliste(kl);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx",
                            new String[] { "Betriebe" }, myModel.getRows(), myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    wb.write(response.getOutputStream());
                } else if (cmd.compareTo("Notenliste") == 0) {
                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = cmd + "_" + kl.getKNAME() + "_"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);

                    myModel = getModelNotenliste(kl, idSchuljahr);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx",
                            new String[] { "Notenliste" }, myModel.getRows(), myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    wb.write(response.getOutputStream());

                } else if (cmd.compareTo("Fehlzeiten") == 0) {
                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = cmd + "_" + kl.getKNAME() + "_"
                            + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);

                    myModel = getModelFehlzeiten(kl, parsedFrom, parsedTo);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx",
                            new String[] { "Fehlzeiten" }, myModel.getRows(), myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    wb.write(response.getOutputStream());
                } else if (cmd.compareTo("Anwesenheit") == 0) {
                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = cmd + "_" + kl.getKNAME() + "_"
                            + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);

                    myModel = getModelAnwesenheit(kl, parsedFrom, parsedTo, anwFilter1, anwFilter2);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx",
                            new String[] { "Anwesenheit" }, myModel.getRows(), myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    wb.write(response.getOutputStream());

                } else if (cmd.compareTo("Verlauf") == 0) {

                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = cmd + "_" + kl.getKNAME() + "_"
                            + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);

                    myModel = getModelVerlauf(kl, parsedFrom, parsedTo, filter1, filter2, me);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + cmd + ".xlsx",
                            new String[] { "Unterrichtsverlauf" }, myModel.getRows(), myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    wb.write(response.getOutputStream());
                } else if (cmd.compareTo("UmfrageAuswertung") == 0) {
                    Umfrage u = em.find(Umfrage.class, anwFilter1);
                    Umfrage u2 = em.find(Umfrage.class, anwFilter2);
                    response.setContentType(
                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
                    response.setCharacterEncoding("UTF-8");
                    String fileName = "Auswertung_" + u.getNAME() + "_vom_"
                            + new java.sql.Date(parsedTo.getTime()).toString() + ".xlsx";
                    fileName = URLEncoder.encode(fileName, "UTF-8");
                    String contentDisposition = "attachment; filename=\"" + fileName + "\"; filename*=UTF-8''"
                            + fileName;
                    response.addHeader("Content-Disposition", contentDisposition);
                    List<UmfrageResult> res1 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter1, filter1);
                    List<UmfrageResult> res2 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter2, filter2);
                    res2 = UmfrageUtil.getComparableResultList(res1, res2);
                    myModel = getModelUmfrageAuswertung(res1);
                    XSSFWorkbook wb = ExcelUtil.readExcel(
                            Config.getInstance().TEMPLATE_FILE_PATH + u.getNAME() + ".xlsx",
                            new String[] { "Hauptgruppe", "Vergleichsgruppe", "Info" }, myModel.getRows(),
                            myModel.getCols());
                    wb = myModel.toExcel(wb, 0);
                    myModel = getModelUmfrageAuswertung(res2);
                    wb = myModel.toExcel(wb, 1);
                    XSSFSheet s = wb.getSheetAt(2);
                    XSSFRow r = s.getRow(0);
                    r.getCell(0).setCellValue(u.getNAME());
                    r.getCell(1).setCellValue(filter1);
                    r = s.getRow(1);
                    r.getCell(0).setCellValue(u2.getNAME());
                    r.getCell(1).setCellValue(filter2);
                    wb.write(response.getOutputStream());
                } else {
                    PrintWriter out = response.getWriter();
                    response.setContentType("application/json; charset=UTF-8");
                    String r = "{\"error\":true,\"msg\":\"Kann fr " + cmd + " kein Datenmodell erzeugen!\"}";
                    out.print(r);
                }
            } else {
                response.setContentType("application/pdf");
                //Get the output stream for writing PDF object        
                OutputStream out = response.getOutputStream();
                try {
                    String kopf = "";
                    kopf += ("<table border='1' align='center' width='100%'>");
                    kopf += ("<tr>");
                    kopf += ("<td rowspan=\"3\" width='150px'></td>");
                    kopf += ("<td align='center'><h2>Multi Media Berufsbildende Schulen Hannover</h2></td>");
                    if (cmd.compareTo("Verlauf") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Unterrichtsverlauf</b></td>");
                    } else if (cmd.compareTo("Anwesenheit") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Anwesenheit</b></td>");
                    } else if (cmd.compareTo("Fehlzeiten") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Fehlzeiten</b></td>");
                    } else if (cmd.compareTo("Stundenplan") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Stundenplan</b></td>");
                    } else if (cmd.compareTo("Vertretungsplan") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Vertretungsplan</b></td>");
                    } else if (cmd.compareTo("Notenliste") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Notenliste</b></td>");
                    } else if (cmd.compareTo("Betriebe") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Betriebsliste</b></td>");
                    } else if (cmd.compareTo("UmfrageAuswertung") == 0) {
                        kopf += ("<td colspan=\"2\" align='center'><b>Digitales Klassenbuch Auswertung Umfrage</b></td>");
                    }
                    kopf += ("</tr>");
                    kopf += ("<tr>");
                    if (cmd.compareTo("UmfrageAuswertung") == 0) {
                        Umfrage u1 = em.find(Umfrage.class, anwFilter1);
                        Umfrage u2 = em.find(Umfrage.class, anwFilter2);
                        kopf += ("<td  align='center' rowspan=\"2\" style=\"padding:5px;font-size: 11\">Hauptgruppe: ("
                                + u1.getNAME() + "/" + filter1 + ")<br></br> Vergleichsgruppe: (" + u2.getNAME()
                                + "/" + filter2 + ")</td>");
                    } else {
                        kopf += ("<td  align='center' rowspan=\"2\"><h3>Klasse/ Kurs: " + kl.getKNAME()
                                + "</h3></td>");
                    }
                    kopf += ("<td  style=\"font-size: 11;\">Verantwortlicher: " + kl.getID_LEHRER() + "</td>");
                    kopf += ("<td  style=\"font-size: 11;\">geprft</td>");
                    kopf += ("</tr>");
                    kopf += ("<tr>");
                    DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
                    Calendar c = df.getCalendar();
                    c.setTimeInMillis(System.currentTimeMillis());
                    String dat = c.get(Calendar.DAY_OF_MONTH) + "." + (c.get(Calendar.MONTH) + 1) + "."
                            + c.get(Calendar.YEAR);
                    kopf += ("<td  style=\"font-size: 11;\">Ausdruck am: " + dat + "</td>");
                    kopf += ("<td  style=\"font-size: 11;\">Datum</td>");
                    kopf += ("</tr>");
                    kopf += ("</table>");
                    kopf += ("<p>&nbsp;</p>");

                    Document document;
                    if (cmd.compareTo("Verlauf") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Verlauf_" + kl.getKNAME() + "_"
                                        + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        document = createVerlauf(kl, kopf, parsedFrom, parsedTo, out, filter1, filter2, me);
                    } else if (cmd.compareTo("Portfolio") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Portfolio_" + kl.getKNAME() + ".pdf");
                        document = createPortfolio(kl, out);
                    } else if (cmd.compareTo("Anwesenheit") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Anwesenheit_" + kl.getKNAME() + "_"
                                        + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        document = createAnwesenheit(kl, kopf, parsedFrom, parsedTo, out, anwFilter1,
                                anwFilter2);
                    } else if (cmd.compareTo("Fehlzeiten") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Fehlzeiten_" + kl.getKNAME() + "_"
                                        + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        MyTableDataModel myModel = getModelFehlzeiten(kl, parsedFrom, parsedTo);
                        document = createFehlzeiten(kl, kopf, parsedFrom, parsedTo, out);
                    } else if (cmd.compareTo("Vertretungsliste") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Vertretungsliste_"
                                        + new java.sql.Date(parsedFrom.getTime()).toString() + "-"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        document = createVertretungsliste(parsedFrom, parsedTo, out);
                    } else if (cmd.compareTo("Notenliste") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Notenliste_" + kl.getKNAME() + "_"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        MyTableDataModel myModel = getModelNotenliste(kl, idSchuljahr);
                        Schuljahr schuljahr = em.find(Schuljahr.class, idSchuljahr);
                        document = createNotenliste(myModel, kopf, out, schuljahr.getNAME());
                    } else if (cmd.compareTo("Betriebe") == 0) {
                        response.addHeader("Content-Disposition",
                                "attachment; filename=Betriebsliste_" + kl.getKNAME() + "_"
                                        + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        MyTableDataModel myModel = getModelBetriebsliste(kl);
                        document = createBetriebsListe(myModel, kopf, out);
                    } else if (cmd.compareTo("UmfrageAuswertung") == 0) {
                        response.addHeader("Content-Disposition", "attachment; filename=UmfrageAuswertung_"
                                + new java.sql.Date(parsedTo.getTime()).toString() + ".pdf");
                        List<UmfrageResult> res1 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter1, filter1);
                        List<UmfrageResult> res2 = UmfrageUtil.getUmfrageResult(em, auth, anwFilter2, filter2);
                        res2 = UmfrageUtil.getComparableResultList(res1, res2);
                        if (res1 != null && res2 != null) {
                            Log.d("erzeuge pdf Dokument");
                            document = createUmfrageauswertung(res1, res2, anwFilter1, anwFilter2, filter1,
                                    filter2, kopf, out);
                        }
                    }

                } catch (DocumentException exc) {
                    Log.d("Document Exception " + exc.getMessage());
                    exc.printStackTrace();
                    throw new IOException(exc.getMessage());
                } catch (ParseException ex) {
                    Log.d("Parse Exception " + ex.getMessage());
                    Logger.getLogger(DokuServlet.class.getName()).log(Level.SEVERE, null, ex);
                } finally {
                    out.close();
                }

            }

        } else {
            response.setContentType("text/html;charset=UTF-8");
            try (PrintWriter out = response.getWriter()) {
                out.println("<!DOCTYPE html>");
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Doku Servlet Usage</title>");
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>You are not authorized</h1>");
                out.println("</body>");
                out.println("</html>");
            }
        }
    }
}