Example usage for org.joda.time DateTimeZone UTC

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

Introduction

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

Prototype

DateTimeZone UTC

To view the source code for org.joda.time DateTimeZone UTC.

Click Source Link

Document

The time zone for Universal Coordinated Time

Usage

From source file:com.moss.jodapersist.YearMonthDayUserType.java

License:Open Source License

public void nullSafeSet(PreparedStatement statement, Object value, int index)
        throws HibernateException, SQLException {
    YearMonthDay ymd = (YearMonthDay) value;

    if (ymd != null) {
        if (sqltype.equals(this.DB_FORMAT_NUMERIC)) {
            statement.setLong(index, yearMonthDayToLong(ymd));
        } else if (sqltype.equals(this.DB_FORMAT_DATETIME)) {
            Instant instant = ymd.toDateTimeAtMidnight().toInstant();

            if (timeOffset.equals(TIME_OFFSET_NOON)) {
                instant = instant.toDateTime(DateTimeZone.UTC).plusHours(12).toInstant();
            }// w ww.j  a  v a  2s.  c  o  m

            statement.setTimestamp(index, new Timestamp(instant.getMillis()), storageCalendar);
        } else if (sqltype.equals(this.DB_FORMAT_STRING)) {
            statement.setString(index, ymd.toString());
        } else
            throw new Error("No valid sqlType specified!");
    } else {
        statement.setNull(index, getNullType());
    }
}

From source file:com.mycollab.configuration.SiteConfiguration.java

License:Open Source License

public static void loadConfiguration() {
    TimeZone.setDefault(DateTimeZone.UTC.toTimeZone());
    DateTimeZone.setDefault(DateTimeZone.UTC);
    int serverPort = Integer.parseInt(System.getProperty(ApplicationProperties.MYCOLLAB_PORT, "8080"));
    ApplicationProperties.loadProps();/*from  w  w w.  j  a  v  a2 s  .c o  m*/
    instance = new SiteConfiguration();

    instance.sentErrorEmail = ApplicationProperties.getString(ERROR_SENDTO, "support@mycollab.com");
    instance.siteName = ApplicationProperties.getString(SITE_NAME, "MyCollab");
    instance.serverAddress = ApplicationProperties.getString(SERVER_ADDRESS, "localhost");
    instance.serverPort = serverPort;
    String propLocale = ApplicationProperties.getString(DEFAULT_LOCALE, "en_US");
    try {
        instance.defaultLocale = Locale.forLanguageTag(propLocale);
    } catch (Exception e) {
        instance.defaultLocale = Locale.US;
    }

    String pullMethodValue = ApplicationProperties.getString(ApplicationProperties.PULL_METHOD, "push");
    instance.pullMethod = PullMethod.valueOf(pullMethodValue);

    instance.cdnUrl = String.format(ApplicationProperties.getString(CDN_URL), instance.serverAddress,
            instance.serverPort);

    instance.appUrl = String.format(ApplicationProperties.getString(APP_URL), instance.serverAddress,
            instance.serverPort);
    if (!instance.appUrl.endsWith("/")) {
        instance.appUrl += "/";
    }

    instance.apiUrl = ApplicationProperties.getString(API_URL, "https://api.mycollab.com/api/");
    instance.endecryptPassword = ApplicationProperties.getString(BI_ENDECRYPT_PASSWORD, "esofthead321");

    // load email
    String host = ApplicationProperties.getString(MAIL_SMTPHOST);
    String user = ApplicationProperties.getString(MAIL_USERNAME);
    String password = ApplicationProperties.getString(MAIL_PASSWORD);
    Integer port = Integer.parseInt(ApplicationProperties.getString(MAIL_PORT, "25"));
    Boolean isTls = Boolean.parseBoolean(ApplicationProperties.getString(MAIL_IS_TLS, "false"));
    Boolean isSsl = Boolean.parseBoolean(ApplicationProperties.getString(MAIL_IS_SSL, "false"));
    String noreplyEmail = ApplicationProperties.getString(MAIL_NOTIFY, "");
    instance.emailConfiguration = new EmailConfiguration(host, user, password, port, isTls, isSsl,
            noreplyEmail);

    // load database configuration
    String driverClass = ApplicationProperties.getString(DB_DRIVER_CLASS);
    String dbUrl = ApplicationProperties.getString(DB_URL);
    String dbUser = ApplicationProperties.getString(DB_USERNAME);
    String dbPassword = ApplicationProperties.getString(DB_PASSWORD);
    instance.databaseConfiguration = new DatabaseConfiguration(driverClass, dbUrl, dbUser, dbPassword);

    instance.resourceDownloadUrl = ApplicationProperties.getString(RESOURCE_DOWNLOAD_URL);
    if (!"".equals(instance.resourceDownloadUrl)) {
        instance.resourceDownloadUrl = String.format(instance.resourceDownloadUrl, instance.serverAddress,
                instance.serverPort);
    } else {
        instance.resourceDownloadUrl = instance.appUrl + "file/";
    }

    instance.dropboxCallbackUrl = ApplicationProperties.getString(DROPBOX_AUTH_LINK);
    instance.ggDriveCallbackUrl = ApplicationProperties.getString(GOOGLE_DRIVE_LINK);

    instance.facebookUrl = ApplicationProperties.getString(FACEBOOK_URL, "https://www.facebook.com/mycollab2");
    instance.twitterUrl = ApplicationProperties.getString(TWITTER_URL, "https://twitter.com/mycollabdotcom");
    instance.googleUrl = ApplicationProperties.getString(GOOGLE_URL,
            "https://plus.google.com/u/0/b/112053350736358775306/+Mycollab/about/p/pub");
    instance.linkedinUrl = ApplicationProperties.getString(LINKEDIN_URL,
            "http://www.linkedin.com/company/mycollab");

    Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
    configuration.setDefaultEncoding("UTF-8");
    try {
        List<TemplateLoader> loaders = new ArrayList<>();
        File i18nFolder = new File(FileUtils.getUserFolder(), "i18n");
        File confFolder1 = new File(FileUtils.getUserFolder(), "conf");
        File confFolder2 = new File(FileUtils.getUserFolder(), "src/main/conf");
        if (i18nFolder.exists()) {
            loaders.add(new FileTemplateLoader(i18nFolder));
        }
        if (confFolder1.exists()) {
            loaders.add(new FileTemplateLoader(confFolder1));
        }
        if (confFolder2.exists()) {
            loaders.add(new FileTemplateLoader(confFolder2));
        }
        loaders.add(new ClassTemplateLoader(SiteConfiguration.class.getClassLoader(), ""));
        configuration.setTemplateLoader(
                new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()])));
        instance.freemarkerConfiguration = configuration;
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}

From source file:com.mycollab.core.utils.DateTimeUtils.java

License:Open Source License

/**
 * @param date//from   www .  jav  a 2s. c  o  m
 * @return
 */
public static Date convertDateTimeToUTC(Date date) {
    return convertDateTimeByTimezone(date, DateTimeZone.UTC.toTimeZone());
}

From source file:com.mycollab.module.project.view.ticket.CreatedDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket ticket : tickets) {
        if (ticket.getCreatedTime() != null) {
            Date createdDate = ticket.getCreatedTime();
            DateTime jodaTime = new DateTime(createdDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (createdDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = createdDateAvailables.get(time);
                groupComponent.insertTicket(ticket);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                createdDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(ticket);
            }// w w  w.  ja  v a 2s .  c  om
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks, 0);
            }
            unspecifiedTasks.insertTicket(ticket);
        }
    }
}

From source file:com.mycollab.module.project.view.ticket.DueDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket ticket : tickets) {
        if (ticket.getDueDate() != null) {
            Date dueDate = ticket.getDueDate();
            DateTime jodaTime = new DateTime(dueDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (dueDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = dueDateAvailables.get(time);
                groupComponent.insertTicket(ticket);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                dueDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(ticket);
            }/*from ww w. j  a va2s.  c om*/
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks);
            }
            unspecifiedTasks.insertTicket(ticket);
        }
    }
}

From source file:com.mycollab.module.project.view.ticket.StartDateOrderComponent.java

License:Open Source License

@Override
public void insertTickets(List<ProjectTicket> tickets) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getLongDateFormat())
            .withLocale(UserUIContext.getUserLocale());
    for (ProjectTicket task : tickets) {
        if (task.getStartDate() != null) {
            Date startDate = task.getStartDate();
            DateTime jodaTime = new DateTime(startDate, DateTimeZone.UTC);
            DateTime monDay = jodaTime.dayOfWeek().withMinimumValue();
            String monDayStr = formatter.print(monDay);
            Long time = new LocalDate(monDay).toDate().getTime();
            if (startDateAvailables.containsKey(time)) {
                DefaultTicketGroupComponent groupComponent = startDateAvailables.get(time);
                groupComponent.insertTicket(task);
            } else {
                DateTime maxValue = monDay.dayOfWeek().withMaximumValue();
                String sundayStr = formatter.print(maxValue);
                String titleValue = String.format("%s - %s", monDayStr, sundayStr);

                DefaultTicketGroupComponent groupComponent = new DefaultTicketGroupComponent(titleValue);
                startDateAvailables.put(time, groupComponent);
                addComponent(groupComponent);
                groupComponent.insertTicket(task);
            }/*  www.j av a 2  s . c om*/
        } else {
            if (unspecifiedTasks == null) {
                unspecifiedTasks = new DefaultTicketGroupComponent(
                        UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED));
                addComponent(unspecifiedTasks, 0);
            }
            unspecifiedTasks.insertTicket(task);
        }
    }
}

From source file:com.mycollab.test.rule.EssentialInitRule.java

License:Open Source License

@Override
public Statement apply(Statement base, Description description) {
    SiteConfiguration.loadConfiguration();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    DateTimeZone.setDefault(DateTimeZone.UTC);
    return base;//www.j  a  v a 2s  . c  o  m
}

From source file:com.nesscomputing.event.NessEvent.java

License:Apache License

/**
 * Convenience constructor that assigns the current time in UTC and a random UUID.
 *//*  w w  w.  j  a v  a2 s .c  o m*/
public static NessEvent createEvent(@Nullable final UUID user, @Nonnull final NessEventType type,
        @Nullable final Map<String, ? extends Object> payload) {
    return new NessEvent(user, new DateTime(DateTimeZone.UTC), type, payload, UUID.randomUUID());
}

From source file:com.nesscomputing.event.NessEvent.java

License:Apache License

/**
 * Convenience constructor that assumes no payload.
 *///from  w ww. j av a2 s.  c o m
public static NessEvent createEvent(@Nullable final UUID user, @Nonnull final NessEventType type) {
    return new NessEvent(user, new DateTime(DateTimeZone.UTC), type, Collections.<String, Object>emptyMap(),
            UUID.randomUUID());
}

From source file:com.nesscomputing.event.NessEvent.java

License:Apache License

/**
 * Create a new event.//w ww.  j  a v  a 2  s.  com
 *
 * @param user       user that the event happend for
 * @param timestamp the time when this event entered the system
 * @param type     event type
 * @param payload      arbitrary data
 * @param id         system-assigned uuid
 */
NessEvent(@Nullable final UUID user, @Nullable final DateTime timestamp, @Nonnull final NessEventType type,
        @Nullable final Map<String, ? extends Object> payload, @Nonnull final UUID id) {
    Preconditions.checkArgument(id != null, "id must not be null!");
    Preconditions.checkArgument(type != null, "type must not be null!");

    this.user = user;
    this.timestamp = (timestamp == null) ? new DateTime(DateTimeZone.UTC) : timestamp;
    this.type = type;
    this.id = id;
    this.payload = (payload == null) ? Collections.<String, Object>emptyMap()
            : new HashMap<String, Object>(payload);
}