Example usage for org.joda.time DateTimeZone forID

List of usage examples for org.joda.time DateTimeZone forID

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone forID.

Prototype

@FromString
public static DateTimeZone forID(String id) 

Source Link

Document

Gets a time zone instance for the specified time zone id.

Usage

From source file:name.martingeisse.gargl.application.tools.QueryDslCodeGeneratorMain.java

License:Open Source License

/**
 * The main method.// w  ww . j  a va 2s  . c  o m
 * @param args ...
 * @throws Exception on errors
 */
public static void main(String[] args) throws Exception {
    try (Connection connection = DriverManager.getConnection(
            "jdbc:mysql://localhost/gargl?zeroDateTimeBehavior=convertToNull&useTimezone=false&characterEncoding=utf8&characterSetResults=utf8",
            "root", "")) {
        MetaDataExporter exporter = new MetaDataExporter();
        exporter.setTargetFolder(new File("src/generated/java"));
        exporter.setPackageName("name.martingeisse.gargl.entity");
        exporter.setSerializerClass(MetaDataSerializer.class);
        exporter.setBeanSerializer(new BeanSerializer(true, false));
        exporter.setConfiguration(new CustomMysqlQuerydslConfiguration(new MySQLTemplates(),
                DateTimeZone.forID("Europe/Berlin")));
        exporter.export(connection.getMetaData());
    }
}

From source file:name.martingeisse.miner.server.tools.QueryDslCodeGeneratorMain.java

License:Open Source License

/**
 * The main method./*w w w  . j a v  a2 s . c o  m*/
 * @param args ...
 * @throws Exception on errors
 */
public static void main(String[] args) throws Exception {
    try (Connection connection = DriverManager.getConnection(
            "jdbc:mysql://localhost/miner?zeroDateTimeBehavior=convertToNull&useTimezone=false&characterEncoding=utf8&characterSetResults=utf8",
            "root", "")) {
        MetaDataExporter exporter = new MetaDataExporter();
        exporter.setTargetFolder(new File("src/generated/java"));
        exporter.setPackageName("name.martingeisse.webide.entity");
        exporter.setSerializerClass(MetaDataSerializer.class);
        exporter.setBeanSerializer(new BeanSerializer(false, false));
        exporter.setConfiguration(new CustomMysqlQuerydslConfiguration(new MySQLTemplates(),
                DateTimeZone.forID("Europe/Berlin")));
        exporter.export(connection.getMetaData());
    }
}

From source file:name.martingeisse.slave_services.application.tools.QueryDslCodeGeneratorMain.java

License:Open Source License

/**
 * The main method./* w ww .j  a  va 2 s .  c  om*/
 * @param args ...
 * @throws Exception on errors
 */
public static void main(String[] args) throws Exception {
    try (Connection connection = DriverManager.getConnection(
            "jdbc:mysql://localhost/slave_services?zeroDateTimeBehavior=convertToNull&useTimezone=false&characterEncoding=utf8&characterSetResults=utf8",
            "root", "")) {
        MetaDataExporter exporter = new MetaDataExporter();
        exporter.setTargetFolder(new File("src/generated/java"));
        exporter.setPackageName("name.martingeisse.slave_services.entity");
        exporter.setSerializerClass(MetaDataSerializer.class);
        exporter.setBeanSerializer(new BeanSerializer(true, false));
        exporter.setConfiguration(new CustomMysqlQuerydslConfiguration(new MySQLTemplates(),
                DateTimeZone.forID("Europe/Berlin")));
        exporter.export(connection.getMetaData());
    }
}

From source file:name.martingeisse.webide.application.IdeLauncher.java

License:Open Source License

/**
 * Initializes URL handlers, time zones and the database.
 * @param startBackgroundThreads whether IDE background threads such as the builder thread shall be started
 * @throws IOException on I/O errors//from   www  .  j  av a 2 s .c om
 */
public static void initialize(boolean startBackgroundThreads) throws IOException {

    // read the configuration
    Configuration.initialize();

    // initialize URL handlers
    System.setProperty("java.protocol.handler.pkgs", "name.martingeisse.webide.util.url");

    // initialize time zone
    DateTimeZone timeZone = DateTimeZone.forID("Europe/Berlin");
    JavascriptAssembler.defaultDateFormatter = DateTimeFormat.forPattern("YYYY-MM-dd").withZone(timeZone);
    JavascriptAssembler.defaultDateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss")
            .withZone(timeZone);

    // initialize database
    MysqlDatabaseDescriptor mainDatabase = new MysqlDatabaseDescriptor();
    mainDatabase.setDisplayName("Local database");
    mainDatabase.setUrl(Configuration.getMainDatabaseUrl());
    mainDatabase.setUsername(Configuration.getMainDatabaseUsername());
    mainDatabase.setPassword(Configuration.getMainDatabasePassword());
    mainDatabase.setDefaultTimeZone(timeZone);
    mainDatabase.initialize();
    Databases.main = mainDatabase;
    EntityConnectionManager.initializeDatabaseDescriptors(mainDatabase);

    // initialize classes. TODO: race condition in the event bus if Wicket doesn't start fast enough
    // (will NPE then).
    if (startBackgroundThreads) {
        BuilderThreadNew.createBuilderThread();
    }

}

From source file:name.martingeisse.webide.tools.QueryDslCodeGeneratorMain.java

License:Open Source License

/**
 * The main method./*from  ww  w  .  j  av a 2 s. c o  m*/
 * @param args ...
 * @throws Exception on errors
 */
public static void main(String[] args) throws Exception {
    Connection connection = DriverManager.getConnection(
            "jdbc:mysql://localhost/webide?zeroDateTimeBehavior=convertToNull&useTimezone=false&characterEncoding=utf8&characterSetResults=utf8",
            "root", "");
    MetaDataExporter exporter = new MetaDataExporter();
    exporter.setTargetFolder(new File("generated"));
    exporter.setPackageName("name.martingeisse.webide.entity");
    exporter.setSerializerClass(MetaDataSerializer.class);
    exporter.setBeanSerializer(new BeanSerializer(false));
    exporter.setConfiguration(
            new CustomMysqlQuerydslConfiguration(new MySQLTemplates(), DateTimeZone.forID("Europe/Berlin")));
    exporter.export(connection.getMetaData());
    connection.close();
}

From source file:name.martingeisse.wicket.application.MyWicketSession.java

License:Open Source License

/**
 * Constructor./*  w w  w .  ja  v a2 s .  c o  m*/
 * @param request the request used to initialize the session
 */
public MyWicketSession(final Request request) {
    super(request);
    this.dataContainer = new ClassKeyedContainer<Object>();
    this.pageId = (new Random().nextInt() & 0xffffff);

    // TODO
    // setLocale(Locale.GERMANY);
    this.timeZone = DateTimeZone.forID("Europe/Berlin"); // DateTimeZone.getDefault();
}

From source file:name.martingeisse.wicket.demo_app.InitializationContextListener.java

License:Open Source License

@Override
public void contextInitialized(ServletContextEvent event) {
    // TODO set default locale
    DateTimeZone.setDefault(DateTimeZone.UTC);
    Constants.timeZone = DateTimeZone.forID("Europe/Berlin");
    Constants.internalDateFormatter = DateTimeFormat.forPattern("YYYY-MM-dd").withZone(Constants.timeZone);
    Constants.internalDateTimeFormatter = DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss")
            .withZone(Constants.timeZone);
    Constants.loggingDateFormatter = DateTimeFormat.forPattern("dd.MM.YYYY").withZone(Constants.timeZone);
    Constants.loggingDateTimeFormatter = DateTimeFormat.forPattern("dd.MM.YYYY HH:mm:ss")
            .withZone(Constants.timeZone);
    Constants.uiDateFormatter = Constants.loggingDateFormatter;
    Constants.uiDateTimeFormatter = Constants.loggingDateTimeFormatter;
}

From source file:nc.noumea.mairie.organigramme.core.transformer.MSDateTransformer.java

License:Open Source License

@SuppressWarnings("rawtypes")
@Override//from  ww  w.j av a2s. c o m
public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass) {

    Matcher matcher = msDateFormatPattern.matcher(value.toString());

    try {
        matcher.find();

        String timestamp = matcher.group(1);
        String timeZone = matcher.group(2);

        DateTime dt;

        if (timeZone != null)
            dt = new DateTime(Long.parseLong(timestamp), DateTimeZone.forID(timeZone));
        else
            dt = new DateTime(Long.parseLong(timestamp), DateTimeZone.UTC);

        return dt.toDate();
    } catch (Exception ex) {
        throw new JSONException(
                String.format("Unable to parse '%s' as a valid date time. Expected format is '%s'",
                        value.toString(), msDateFormat),
                ex);
    }
}

From source file:nc.noumea.mairie.organigramme.core.utility.DateUtil.java

License:Open Source License

private static DateTimeFormatter dateTimeFormatterNCForPattern(String pattern) {
    return DateTimeFormat.forPattern(pattern).withZone(DateTimeZone.forID(TIMEZONE_NOUMEA));
}

From source file:nc.noumea.mairie.organigramme.core.utility.JsonDateDeserializer.java

License:Open Source License

@Override
public Date deserialize(JsonParser arg0, DeserializationContext arg1)
        throws IOException, JsonProcessingException {

    if (arg0 == null) {
        return null;
    }/*from  w  ww .  ja v a 2s .  c  om*/

    Matcher matcher = msDateFormatPattern.matcher(arg0.getText());

    try {
        matcher.find();

        String timestamp = matcher.group(1);
        String timeZone = matcher.group(2);

        DateTime dt;

        if (timeZone != null)
            dt = new DateTime(Long.parseLong(timestamp), DateTimeZone.forID(timeZone));
        else
            dt = new DateTime(Long.parseLong(timestamp), DateTimeZone.UTC);

        return dt.toDate();
    } catch (Exception ex) {
        throw new JSONException(
                String.format("Unable to parse '%s' as a valid date time. Expected format is '%s'",
                        arg0.toString(), msDateFormat),
                ex);
    }
}