Example usage for java.util TimeZone getID

List of usage examples for java.util TimeZone getID

Introduction

In this page you can find the example usage for java.util TimeZone getID.

Prototype

public String getID() 

Source Link

Document

Gets the ID of this time zone.

Usage

From source file:org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage.java

protected void updateTimeZone(final String timeZoneID) {
    m_timezone = null;//from  www.jav  a2  s.c om

    if (timeZoneID != null) {
        final TimeZone timeZone = TimeZone.getTimeZone(timeZoneID.toUpperCase());
        // Only set, if timezone could be parsed
        if (!timeZone.getID().equals("GMT") || timeZoneID.toUpperCase().equals("GMT")) //$NON-NLS-1$ //$NON-NLS-2$
            m_timezone = timeZone;
    }

    validate();
}

From source file:dk.teachus.backend.testdatagenerator.DynamicDataImport.java

private void createDefaultTimezone(TimeZone timeZone) {
    Session session = sessionFactory.openSession();
    session.beginTransaction();//from  w  ww .j a  v a 2s.c  o  m

    ApplicationConfigurationEntry entry = new ApplicationConfigurationEntry(
            ApplicationConfiguration.DEFAULT_TIMEZONE, timeZone.getID());
    session.save(entry);

    session.getTransaction().commit();
    session.close();
}

From source file:com.serotonin.m2m2.Lifecycle.java

public synchronized void initialize(ClassLoader classLoader) {
    for (Module module : ModuleRegistry.getModules()) {
        module.preInitialize();//from   w  w w  . j  a v a 2 s.c  om
    }

    String tzId = Common.envProps.getString("timezone");
    if (!StringUtils.isEmpty(tzId)) {
        TimeZone tz = TimeZone.getTimeZone(tzId);
        if ((tz == null) || (!tz.getID().equals(tzId)))
            throw new RuntimeException("Time zone id '" + tzId + "' in env properties is not valid");
        this.LOG.info("Setting default time zone to " + tz.getID());
        TimeZone.setDefault(tz);
        DateTimeZone.setDefault(DateTimeZone.forID(tzId));
    }

    Common.timer.init(new ThreadPoolExecutor(0, 1000, 30L, TimeUnit.SECONDS, new SynchronousQueue()));

    Providers.add(TimerProvider.class, new TimerProvider() {
        public AbstractTimer getTimer() {
            return Common.timer;
        }
    });
    Common.JSON_CONTEXT.addResolver(new EventTypeResolver(), new Class[] { EventType.class });
    Common.JSON_CONTEXT.addResolver(new BaseChartRenderer.Resolver(), new Class[] { ChartRenderer.class });
    Common.JSON_CONTEXT.addResolver(new BaseTextRenderer.Resolver(), new Class[] { TextRenderer.class });
    Common.JSON_CONTEXT.addResolver(new EmailRecipientResolver(), new Class[] { EmailRecipient.class });

    Providers.add(InputStreamEPollProvider.class, new InputStreamEPollProviderImpl());
    Providers.add(ProcessEPollProvider.class, new ProcessEPollProviderImpl());

    //    lic();
    freemarkerInitialize();
    databaseInitialize(classLoader);

    for (Module module : ModuleRegistry.getModules()) {
        module.postDatabase();
    }
    utilitiesInitialize();
    eventManagerInitialize();
    runtimeManagerInitialize();
    maintenanceInitialize();
    imageSetInitialize();
    webServerInitialize(classLoader);

    for (Module module : ModuleRegistry.getModules()) {
        module.postInitialize();
    }

    SystemEventType.raiseEvent(new SystemEventType("SYSTEM_STARTUP"), System.currentTimeMillis(), false,
            new TranslatableMessage("event.system.startup"));

    for (Runnable task : this.STARTUP_TASKS)
        Common.timer.execute(task);
}

From source file:org.apache.sqoop.connector.jdbc.oracle.util.OracleQueries.java

public static void setConnectionTimeZone(Connection connection, String timeZone) {
    String timeZoneStr = timeZone;
    if (StringUtils.isEmpty(timeZoneStr)) {
        timeZoneStr = "GMT";
    }//w  w w.  j a  v a 2 s  .  c  o  m
    TimeZone timeZoneObj = TimeZone.getTimeZone(timeZoneStr);
    try {
        Method methSession = oracleConnectionClass.getMethod("setSessionTimeZone", String.class);
        Method methDefault = oracleConnectionClass.getMethod("setDefaultTimeZone", TimeZone.class);
        methSession.invoke(connection, timeZoneObj.getID());
        methDefault.invoke(connection, timeZoneObj);
        TimeZone.setDefault(timeZoneObj);
        DateTimeZone.setDefault(DateTimeZone.forTimeZone(timeZoneObj));
        LOG.info("Session Time Zone set to " + timeZoneObj.getID());
    } catch (Exception e) {
        LOG.error("Error setting time zone: " + e.getMessage());
    }
}

From source file:fr.bde_eseo.eseomega.events.tickets.TicketHistoryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // Set view / call parent
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_history);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    context = this;

    // Get profile
    // Get user's data
    userProfile = new UserProfile();
    userProfile.readProfilePromPrefs(context);

    // Layout/*w w  w.  jav a 2s .  co  m*/
    progressLoad = (ProgressBar) findViewById(R.id.progressTicketList);
    progressToken = (ProgressBar) findViewById(R.id.progressLoading);
    progressLoad.setVisibility(View.GONE);
    progressLoad.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500),
            PorterDuff.Mode.SRC_IN);
    progressToken.setVisibility(View.INVISIBLE);
    progressToken.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_white_1000),
            PorterDuff.Mode.SRC_IN);
    tvNothing = (TextView) findViewById(R.id.tvListNothing);
    tvNothing2 = (TextView) findViewById(R.id.tvListNothing2);
    imgNothing = (ImageView) findViewById(R.id.imgNoCommand);
    tvNothing.setVisibility(View.GONE);
    tvNothing2.setVisibility(View.GONE);
    imgNothing.setVisibility(View.GONE);
    viewToken = findViewById(R.id.viewCircle);
    viewToken.setVisibility(View.INVISIBLE);

    // Get file from cache directory
    String cachePath = getCacheDir() + "/";
    cacheTicketsJSON = new File(cachePath + "tickets.json");

    // Init model  get it from TicketStore
    eventTicketItems = TicketStore.getInstance().getEventTicketItems();

    // Init adapter / recycler view
    mAdapter = new MyTicketAdapter(context);
    recList = (RecyclerView) findViewById(R.id.cardTickets);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(context);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    recList.setAdapter(mAdapter);
    recList.setVisibility(View.GONE);

    // Attach floating action button
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.attachToRecyclerView(recList);

    // On click listener for token
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TimeZone tz = Calendar.getInstance().getTimeZone();
            String tzStr = tz.getID();

            if (!userProfile.isCreated()) {
                new MaterialDialog.Builder(context).title("Vous n'tes pas connect").content(
                        "Nous avons besoin de savoir qui vous tes avant de pouvoir vous laisser effectuer une rservation.")
                        .negativeText("D'accord").cancelable(false).show();
            } else if (false && !tzStr.equalsIgnoreCase(Constants.TZ_ID_PARIS)) {
                new MaterialDialog.Builder(context).title("Erreur").content(
                        "L'accs aux rservations ne peut se faire depuis un autre pays que la France.\nEnvoyez nous une carte postale !")
                        .negativeText("D'accord").cancelable(false).show();
            } else {
                SyncToken syncToken = new SyncToken();
                syncToken.execute();
            }
        }
    });

    // Recycler listener
    recList.addOnItemTouchListener(
            new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {

                    final int idcmd = eventTicketItems.get(position).getIdcmd();

                    new MaterialDialog.Builder(context).title("Renvoyer l'email").content(
                            "Vous avez perdu votre place, vous ne retouvez plus le mail associ ?\nPas de soucis, vous avez la possibilit de recevoir de nouveau votre place ...")
                            .negativeText(R.string.dialog_cancel).callback(new MaterialDialog.ButtonCallback() {
                                @Override
                                public void onNegative(MaterialDialog dialog) {
                                    Utilities.hideKeyboardFromActivity(TicketHistoryActivity.this); // Doesn't works ...
                                    super.onNegative(dialog);
                                }
                            }).inputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
                            .input("sterling@archer.fr", "", new MaterialDialog.InputCallback() {
                                @Override
                                public void onInput(MaterialDialog dialog, CharSequence input) {
                                    AsyncEventEmail asyncEmail = new AsyncEventEmail(context, "" + input, null,
                                            userProfile, idcmd); // convert charSequence into String object
                                    asyncEmail.execute();
                                }
                            }).show();
                }
            }));

    // Change message
    if (userProfile.isCreated()) {
        tvNothing.setText(getResources().getString(R.string.empty_header_order));
        tvNothing2.setText(getResources().getString(R.string.empty_desc_order));
    } else {
        tvNothing.setText(getResources().getString(R.string.empty_header_noorder));
        tvNothing2.setText(getResources().getString(R.string.empty_desc_noorder));
        tvNothing.setVisibility(View.VISIBLE);
        tvNothing2.setVisibility(View.VISIBLE);
        imgNothing.setVisibility(View.VISIBLE);
        fab.setVisibility(View.GONE);
    }

    // Set data
    mAdapter.setTicketsItems(eventTicketItems);

    // Start update
    if (mHandler == null) {
        mHandler = new android.os.Handler();
        mHandler.postDelayed(updateTimerThread, RUN_START);
    } else {
        mHandler.removeCallbacks(updateTimerThread);
        mHandler.postDelayed(updateTimerThread, RUN_START);
    }

    // Delay to update data
    run = true;

}

From source file:com.googlecode.android_scripting.facade.AndroidFacade.java

/**
 * /* www. j a v a2s  .co  m*/
 * Map returned:
 * 
 * <pre>
 *   TZ = Timezone
 *     id = Timezone ID
 *     display = Timezone display name
 *     offset = Offset from UTC (in ms)
 *   SDK = SDK Version
 *   download = default download path
 *   appcache = Location of application cache 
 *   sdcard = Space on sdcard
 *     availblocks = Available blocks
 *     blockcount = Total Blocks
 *     blocksize = size of block.
 * </pre>
 */
@Rpc(description = "A map of various useful environment details")
public Map<String, Object> environment() {
    Map<String, Object> result = new HashMap<String, Object>();
    Map<String, Object> zone = new HashMap<String, Object>();
    Map<String, Object> space = new HashMap<String, Object>();
    TimeZone tz = TimeZone.getDefault();
    zone.put("id", tz.getID());
    zone.put("display", tz.getDisplayName());
    zone.put("offset", tz.getOffset((new Date()).getTime()));
    result.put("TZ", zone);
    result.put("SDK", android.os.Build.VERSION.SDK);
    result.put("download", FileUtils.getExternalDownload().getAbsolutePath());
    result.put("appcache", mService.getCacheDir().getAbsolutePath());
    try {
        StatFs fs = new StatFs("/sdcard");
        space.put("availblocks", fs.getAvailableBlocks());
        space.put("blocksize", fs.getBlockSize());
        space.put("blockcount", fs.getBlockCount());
    } catch (Exception e) {
        space.put("exception", e.toString());
    }
    result.put("sdcard", space);
    return result;
}

From source file:fr.bde_eseo.eseomega.lacommande.OrderHistoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Find elements and attach listView / floating button
    View rootView = inflater.inflate(R.layout.fragment_cafet_history, container, false);

    // Get current fragment's context
    context = getActivity();//from   w  w  w .jav  a 2 s  .c  o m

    // Get user's data
    userProfile = new UserProfile();
    userProfile.readProfilePromPrefs(getActivity());
    userLogin = userProfile.getId();
    userPass = userProfile.getPassword();

    // Search for the listView, then set its adapter
    mAdapter = new MyHistoryAdapter(getActivity());
    recList = (RecyclerView) rootView.findViewById(R.id.cardHistory);
    progressBar = (ProgressBar) rootView.findViewById(R.id.progressHistoryList);
    progressBarToken = (ProgressBar) rootView.findViewById(R.id.progressLoading);
    viewToken = rootView.findViewById(R.id.viewCircle);
    tvNothing = (TextView) rootView.findViewById(R.id.tvListNothing);
    tvNothing2 = (TextView) rootView.findViewById(R.id.tvListNothing2);
    tvServiceInfo = (TextView) rootView.findViewById(R.id.tvServiceInfo);
    imgNothing = (ImageView) rootView.findViewById(R.id.imgNoCommand);
    recList.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    recList.setAdapter(mAdapter);
    recList.setVisibility(View.GONE);
    progressBar.setVisibility(View.GONE);
    progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500),
            PorterDuff.Mode.SRC_IN);
    progressBarToken.setVisibility(View.INVISIBLE);
    progressBarToken.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_white_1000),
            PorterDuff.Mode.SRC_IN);
    viewToken.setVisibility(View.INVISIBLE);
    tvNothing.setVisibility(View.GONE);
    tvNothing2.setVisibility(View.GONE);
    imgNothing.setVisibility(View.GONE);

    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.attachToRecyclerView(recList);

    // Change message
    if (userProfile.isCreated()) {
        tvNothing.setText(getActivity().getResources().getString(R.string.empty_header_history));
        tvNothing2.setText(getActivity().getResources().getString(R.string.empty_desc_history));
    } else {
        tvNothing.setText(getActivity().getResources().getString(R.string.empty_header_noconnect));
        tvNothing2.setText(getActivity().getResources().getString(R.string.empty_desc_noconnect));
        tvNothing.setVisibility(View.VISIBLE);
        tvNothing2.setVisibility(View.VISIBLE);
        imgNothing.setVisibility(View.VISIBLE);
        fab.setVisibility(View.GONE);
    }

    // Get file from cache directory
    String cachePath = getActivity().getCacheDir() + "/";
    cacheHistoryJSON = new File(cachePath + "history.json");

    // Create array and check online history
    historyList = new ArrayList<>();

    // Delay to update data
    run = true;

    if (mHandler == null) {
        mHandler = new android.os.Handler();
        mHandler.postDelayed(updateTimerThread, RUN_START);
    } else {
        mHandler.removeCallbacks(updateTimerThread);
        mHandler.postDelayed(updateTimerThread, RUN_START);
    }
    mAdapter.setHistoryArray(historyList);

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            TimeZone tz = Calendar.getInstance().getTimeZone();
            String tzStr = tz.getID();

            if (!userProfile.isCreated()) {
                new MaterialDialog.Builder(getActivity()).title("Vous n'tes pas connect").content(
                        "Nous avons besoin de savoir qui vous tes avant de pouvoir vous laisser commander.")
                        .negativeText("D'accord").cancelable(false).show();
            } else if (false && !tzStr.equalsIgnoreCase(Constants.TZ_ID_PARIS)) {
                new MaterialDialog.Builder(getActivity()).title("Erreur").content(
                        "L'accs  la Cafet ne peut se faire depuis un autre pays que la France.\nEnvoyez nous une carte postale !")
                        .negativeText("D'accord").cancelable(false).show();
            } else {

                String versionName = BuildConfig.VERSION_NAME;

                /** Prepare data **/
                long timestamp = System.currentTimeMillis() / 1000; // timestamp in seconds
                params = new HashMap<>();
                params.put(getActivity().getResources().getString(R.string.client), userLogin);
                params.put(getActivity().getResources().getString(R.string.password), userPass);
                params.put(getActivity().getResources().getString(R.string.tstp), "" + timestamp);
                params.put(getActivity().getResources().getString(R.string.os), "" + Constants.APP_ID);
                params.put(getActivity().getResources().getString(R.string.version), "" + versionName);
                params.put(getActivity().getResources().getString(R.string.hash),
                        EncryptUtils.sha256(getActivity().getResources().getString(R.string.MESSAGE_GET_TOKEN)
                                + userLogin + userPass + timestamp + Constants.APP_ID));

                /** Call async task **/
                SyncTimeToken syncTimeToken = new SyncTimeToken(getActivity());
                syncTimeToken.execute(Constants.URL_API_ORDER_PREPARE);
            }

        }
    });

    recList.addOnItemTouchListener(
            new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    Intent i = new Intent(getActivity(), OrderDetailsActivity.class);
                    i.putExtra(Constants.KEY_ORDER_ID, historyList.get(position).getCommandNumber());
                    getActivity().startActivity(i);
                }
            }));

    // Who's cooking ?
    AsyncInfoService asyncInfoService = new AsyncInfoService();
    asyncInfoService.execute();

    return rootView;
}

From source file:com.jaspersoft.jasperserver.war.action.ReportJobEditAction.java

protected void setTimeZoneData(RequestContext context) {
    if (getTimeZonesList() != null) {
        List timeZones = getTimeZonesList().getTimeZones(getUserLocale());
        context.getRequestScope().put(getTimeZonesAttrName(), timeZones);

        TimeZone userTz = JasperServerUtil.getTimezone(context);
        context.getRequestScope().put("preferredTimezone", userTz.getID());
    }/* ww w  .j  a  v  a  2 s  .c om*/
}

From source file:com.jaspersoft.jasperserver.api.engine.scheduling.domain.ReportJob.java

/**
 * Looks for {@link  net.sf.jasperreports.engine.JRParameter#REPORT_TIME_ZONE REPORT_TIME_ZONE}
 * and returns ID of the {@link java.util.TimeZone Timezone}.
 * If Timezone parameters is not present, or it is null, return null.
 *
 * @return String Timezone ID/*from  ww w  .j  a  v a2 s.c  o m*/
 */
public String getOutputTimeZone() {
    ReportJobSource jobSource = this.getSource();
    if (jobSource != null) {

        Map<String, Object> parameters = jobSource.getParameters();
        if (parameters != null) {
            TimeZone tz = (TimeZone) parameters.get(JRParameter.REPORT_TIME_ZONE);
            return tz != null ? tz.getID() : null;
        }
    }

    return null;
}

From source file:org.kalypso.ogc.sensor.tableview.swing.tablemodel.ObservationTableModel.java

/**
 * Exports the contents of the model//  ww w  . j  av  a 2  s.c o  m
 */
public void dump(final String separator, final BufferedWriter writer) throws IOException {
    if (m_sharedModel.isEmpty())
        return;

    final Object checkObject = m_sharedModel.first();

    // will be used for formating the various columns
    final Format[] nf = new Format[m_columns.size() + 1];

    // find appropriate format for shared column (Attention: can still be null)
    if (checkObject instanceof Date)
        nf[0] = TimeseriesUtils.getDateFormat();
    else if (checkObject instanceof Integer)
        nf[0] = NumberFormat.getIntegerInstance();
    else if (checkObject instanceof Number)
        nf[0] = NumberFormat.getNumberInstance();

    // dump header and fetch numberformats
    writer.write(m_sharedAxis.getName());
    if (nf[0] instanceof DateFormat) {
        final DateFormat df = (DateFormat) nf[0];
        final TimeZone timeZone = df.getTimeZone();
        if (timeZone != null) {
            writer.write(" ("); //$NON-NLS-1$
            writer.write(timeZone.getID());
            writer.write(")"); //$NON-NLS-1$
        }
    }

    int col = 1;
    for (final Object element : m_columns) {
        final TableViewColumn tvc = (TableViewColumn) element;

        nf[col] = TimeseriesUtils.getNumberFormat(tvc.getFormat());

        writer.write(separator);
        writer.write(tvc.getName());

        col++;
    }

    writer.newLine();

    // dump values
    int row = 0;
    for (final Object key : m_sharedModel) {
        writer.write(nf[0] == null ? key.toString() : nf[0].format(key));

        col = 1;
        for (; col < getColumnCount(); col++) {
            final Object value = getValueAt(row, col);

            writer.write(separator);

            if (nf[col] != null && value != null)
                writer.write(nf[col].format(value));
            else
                writer.write(""); //$NON-NLS-1$
        }

        writer.newLine();
        row++;
    }
}