Example usage for java.util Locale GERMAN

List of usage examples for java.util Locale GERMAN

Introduction

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

Prototype

Locale GERMAN

To view the source code for java.util Locale GERMAN.

Click Source Link

Document

Useful constant for language.

Usage

From source file:PrintfExamples.java

public static void main(String[] args) {
    System.out.printf(Locale.ITALIAN, "The date is %tc\n", new Date());
    System.out.printf(Locale.CHINA, "The date is %tc\n", new Date());
    System.out.printf(Locale.FRENCH, "The date is %tc\n", new Date());
    System.out.printf(Locale.GERMAN, "The date is %tc\n", new Date());
}

From source file:Test.java

public static void main(String[] args) {
    Locale locale = Locale.getDefault();
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);/*from  w  w w  . j  a v a  2  s.c  o m*/

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

    Locale.setDefault(Locale.Category.FORMAT, Locale.JAPANESE);
    Locale.setDefault(Locale.Category.DISPLAY, Locale.GERMAN);

    System.out.println(
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println("" + locale.getDisplayLanguage());

}

From source file:com.spring.tutorial.messages.App.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
            "com/spring/tutorial/messages/applicationContext.xml");
    MessageSource ms = ctx.getBean(MessageSource.class);
    //Message resolution
    String success = ms.getMessage("msg.success", null, Locale.getDefault());
    String successEN = ms.getMessage("msg.success", null, Locale.ENGLISH);
    String successFR = ms.getMessage("msg.success", null, Locale.FRENCH);
    String successDE = ms.getMessage("msg.success", null, Locale.GERMAN);
    //Message resolution and i18n
    String label = ms.getMessage("lbl.result", null, Locale.getDefault());
    //Not necessary to pass the locale
    String error = ms.getMessage("err.failure", null, null);
    //Non-existent message (if the call does not specify, the default message argument,
    //and the message code does not exist, an exception will be thrown)
    String nonExistent = ms.getMessage("my.message", null, "Not found, defaults to this message", null);
    LOGGER.info("Success message (es - the default): " + success);
    LOGGER.info("Success message (en): " + successEN);
    LOGGER.info("Success message (fr): " + successFR);
    LOGGER.info("Success message (de) defaults to local language: " + successDE);
    LOGGER.info("Label text: " + label);
    LOGGER.info("Error message: " + error);
    LOGGER.info("Non-existent message (defaults to message specified as argument): " + nonExistent);
    ((ClassPathXmlApplicationContext) ctx).close();
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld = LocalDate.of(2014, Month.JUNE, 21);
    LocalTime lt = LocalTime.of(17, 30, 20);
    LocalDateTime ldt = LocalDateTime.of(ld, lt);

    DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
    System.out.println("Formatter  Default Locale: " + fmt.getLocale());
    System.out.println("Short  Date: " + fmt.format(ld));

    fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
    System.out.println("Medium Date: " + fmt.format(ld));

    fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
    System.out.println("Long  Date: " + fmt.format(ld));

    fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
    System.out.println("Full  Date: " + fmt.format(ld));

    fmt = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
    System.out.println("Short Time:  " + fmt.format(lt));

    fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
    System.out.println("Short  Datetime: " + fmt.format(ldt));

    fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
    System.out.println("Medium Datetime: " + fmt.format(ldt));

    // Use German locale to format the datetime in medius style
    fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.GERMAN);
    System.out.println(fmt.format(ldt));

    // Use Indian(English) locale to format datetime in short style
    fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(new Locale("en", "IN"));
    System.out.println(fmt.format(ldt));

    // Use Indian(English) locale to format datetime in medium style
    fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(new Locale("en", "IN"));
    System.out.println(fmt.format(ldt));

}

From source file:PropertiesDemo.java

static public void main(String[] args) {

    Locale[] supportedLocales = { Locale.FRENCH, Locale.GERMAN, Locale.ENGLISH };

    for (int i = 0; i < supportedLocales.length; i++) {
        displayValue(supportedLocales[i], "s2");
    }//from   ww w . j a  va2  s .  c o m

    System.out.println();

    iterateKeys(supportedLocales[0]);

}

From source file:com.aurel.track.exchange.docx.importer.HTMLParser.java

public static void main(String[] args) {
    HTMLParser htmlParser = new HTMLParser();
    ByteArrayOutputStream byteArrayOutputStream = HtmlConverter.convertToHTML("d:/docx/PN164_SC_Track.docx");
    htmlParser.parse(byteArrayOutputStream, Locale.GERMAN);
    LOGGER.info("Main chapters found:");
    List<ItemNode> mainChapters = htmlContent.getChapters();
    if (mainChapters != null) {
        for (ItemNode itemNode : mainChapters) {
            LOGGER.info(itemNode.getTitle());
        }/*from w ww .  ja v a2s  .c om*/
    }
    //htmlParser.parseDocument("d:/docx/PN164_SC_Track.docx.html", Locale.GERMAN);
}

From source file:de.mendelson.comm.as2.AS2.java

/**Method to start the server on from the command line*/
public static void main(String args[]) {

    // TODO remove
    cleanup();//from www  .ja  va 2  s.c o m

    String language = null;
    boolean startHTTP = true;
    boolean allowAllClients = false;
    int optind;
    for (optind = 0; optind < args.length; optind++) {
        if (args[optind].toLowerCase().equals("-lang")) {
            language = args[++optind];
        } else if (args[optind].toLowerCase().equals("-nohttpserver")) {
            startHTTP = false;
        } else if (args[optind].toLowerCase().equals("-allowallclients")) {
            allowAllClients = true;
        } else if (args[optind].toLowerCase().equals("-?")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-h")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-help")) {
            AS2.printUsage();
            System.exit(1);
        }
    }
    //load language from preferences
    if (language == null) {
        PreferencesAS2 preferences = new PreferencesAS2();
        language = preferences.get(PreferencesAS2.LANGUAGE);
    }
    if (language != null) {
        if (language.toLowerCase().equals("en")) {
            Locale.setDefault(Locale.ENGLISH);
        } else if (language.toLowerCase().equals("de")) {
            Locale.setDefault(Locale.GERMAN);
        } else if (language.toLowerCase().equals("fr")) {
            Locale.setDefault(Locale.FRENCH);
        } else {
            AS2.printUsage();
            System.out.println();
            System.out.println("Language " + language + " is not supported.");
            System.exit(1);
        }
    }
    Splash splash = new Splash("/de/mendelson/comm/as2/client/Splash.jpg");
    AffineTransform transform = new AffineTransform();
    splash.setTextAntiAliasing(false);
    transform.setToScale(1.0, 1.0);
    splash.addDisplayString(new Font("Verdana", Font.BOLD, 11), 7, 262, AS2ServerVersion.getFullProductName(),
            new Color(0x65, 0xB1, 0x80), transform);
    splash.setVisible(true);
    splash.toFront();
    //start server
    try {
        //register the database drivers for the VM
        Class.forName("org.hsqldb.jdbcDriver");
        //initialize the security provider
        BCCryptoHelper helper = new BCCryptoHelper();
        helper.initialize();
        AS2Server as2Server = new AS2Server(startHTTP, allowAllClients);
        AS2Agent agent = new AS2Agent(as2Server);
    } catch (UpgradeRequiredException e) {
        //an upgrade to HSQLDB 2.x is required, delete the lock file
        Logger.getLogger(AS2Server.SERVER_LOGGER_NAME).warning(e.getMessage());
        JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage());
        AS2Server.deleteLockFile();
        System.exit(1);
    } catch (Throwable e) {
        if (splash != null) {
            splash.destroy();
        }
        JOptionPane.showMessageDialog(null, e.getMessage());
        System.exit(1);
    }
    //start client
    AS2Gui gui = new AS2Gui(splash, "localhost");
    gui.setVisible(true);
    splash.destroy();
    splash.dispose();
}

From source file:Main.java

public static String buildIdentificationNumberWithDecimalSeparator(CharSequence number) {
    if (number.length() == 0) {
        return number.toString();
    }//from   w  w w.j av  a  2  s .  c o m
    try {
        Long value = Long.valueOf(number.toString());
        Locale.setDefault(Locale.GERMAN);
        return String.format("%,d", value);
    } catch (NumberFormatException e) {
        return "";
    }
}

From source file:Main.java

/**
 * Gets the day of week out of a date./*from   w ww.j a v a 2s. c  o  m*/
 *
 * @param dateString represents the date.
 * @return the day of week of the date.
 */
public static String dateToDayOfWeek(String dateString) {
    Date date = new Date();
    try {
        date = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.GERMAN).parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    DateFormat dtfmt = new SimpleDateFormat("EEE", Locale.ENGLISH);
    String dayOfWeek = dtfmt.format(date);
    return dayOfWeek;
}

From source file:Main.java

public static String getExamKey(String courseId, String term, long date) {
    return String.format(Locale.GERMAN, "%s-%s-%d", courseId, term, date);
}