Example usage for java.util TimeZone getTimeZone

List of usage examples for java.util TimeZone getTimeZone

Introduction

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

Prototype

public static TimeZone getTimeZone(ZoneId zoneId) 

Source Link

Document

Gets the TimeZone for the given zoneId .

Usage

From source file:com.icloud.framework.http.heritrix.ArchiveUtils.java

private static ThreadLocal<SimpleDateFormat> threadLocalDateFormat(final String pattern) {
    ThreadLocal<SimpleDateFormat> tl = new ThreadLocal<SimpleDateFormat>() {
        protected SimpleDateFormat initialValue() {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            df.setTimeZone(TimeZone.getTimeZone("GMT"));
            return df;
        }//from  ww  w  . j  a  va2s  .  c  om
    };
    return tl;
}

From source file:net.sf.jasperreports.groups.footerposition.FooterPositionTest.java

@Test
public void keepTogetherReports() throws JRException, NoSuchAlgorithmException, IOException {
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put(JRParameter.REPORT_LOCALE, Locale.US);
    params.put(JRParameter.REPORT_TIME_ZONE, TimeZone.getTimeZone("GMT"));

    for (int i = 1; i <= 14; i++) {
        String jrxmlFileName = "net/sf/jasperreports/groups/footerposition/repo/FooterPositionReport." + i
                + ".jrxml";

        JasperReport report = compileReport(jrxmlFileName);

        JasperPrint print = fillManager.fill(report, params);
        assert !print.getPages().isEmpty();

        String xmlExportDigest = xmlExportDigest(print);
        log.debug("Plain report got " + xmlExportDigest);

        String referenceXmlExportDigest = getFileDigest(
                "net/sf/jasperreports/groups/footerposition/repo/FooterPositionReport." + i
                        + ".reference.jrpxml");

        assert xmlExportDigest.equals(referenceXmlExportDigest);
    }//w  ww .j  av a 2 s .c  om
}

From source file:com.hackensack.umc.activity.ViewProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_profile);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    sharedPreferences = getSharedPreferences(Constant.SHAREPREF_TAG, MODE_PRIVATE);
    insuranceInfoTv = (TextView) findViewById(R.id.prof_insurance_tv);
    if (Util.isUserLogin(this) && Util.isPatientIdValid(this)) {

        try {//w w w. j  av a  2  s .  c om
            mPatient = new LoginUserData(new JSONObject(Util.getPatientJSON(this)));
            ((TextView) findViewById(R.id.profile_fname)).setText(mPatient.getFirstName());
            ((TextView) findViewById(R.id.prof_lname)).setText(mPatient.getLastName());
            ((TextView) findViewById(R.id.prof_license)).setText(
                    TextUtils.isEmpty(mPatient.getDrivingLicense()) ? "-" : mPatient.getDrivingLicense());
            DateFormat formatterDate = new SimpleDateFormat("MM-dd-yyyy");

            Date d = null;
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
                d = sdf.parse(mPatient.getBirthDate());
            } catch (Exception e) {
                Log.e("Date", " " + e);
            }

            //Bug is there : Null Pointer : Appointment Date
            ((TextView) findViewById(R.id.prof_date)).setText(formatterDate.format(d.getTime()));
            ((TextView) findViewById(R.id.prof_gender_tv)).setText(mPatient.getGender());
            //Code for getting and displaying phone numbers
            ArrayList<Telecom> telecom = mPatient.getTelephone();
            Log.v("Telecom", telecom.toString());
            String phonestr = null;
            for (int i = 0; i < telecom.size(); i++) {
                if (((Telecom) telecom.get(i)).getSystem().equalsIgnoreCase(Telecom.TELECOM_EMAIL)) {
                    ((TextView) findViewById(R.id.prof_email)).setText(((Telecom) telecom.get(i)).getValue());
                } else if (((Telecom) telecom.get(i)).getSystem().equalsIgnoreCase(Telecom.TELECOM_PHONE)) {
                    phonestr = telecom.get(i).getValue();
                    final Editable doctorPhoneNum = new SpannableStringBuilder(phonestr);
                    PhoneNumberUtils.formatNumber(doctorPhoneNum,
                            PhoneNumberUtils.getFormatTypeForLocale(Locale.US));
                    if (((Telecom) telecom.get(i)).getUse().equalsIgnoreCase(Telecom.TELECOM_MOBILE_PHONE)) {
                        findViewById(R.id.mobile_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_mob_num)).setText(doctorPhoneNum);

                    } else if (((Telecom) telecom.get(i)).getUse()
                            .equalsIgnoreCase(Telecom.TELECOM_HOME_PHONE)) {
                        findViewById(R.id.home_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_home_num)).setText(doctorPhoneNum);

                    } else if (((Telecom) telecom.get(i)).getUse()
                            .equalsIgnoreCase(Telecom.TELECOM_WORK_PHONE)) {
                        findViewById(R.id.work_ll).setVisibility(View.VISIBLE);
                        ((TextView) findViewById(R.id.prof_work_num)).setText(doctorPhoneNum);
                    }
                }
            }
            //Code to get and display address
            if (mPatient.getAddress() != null && mPatient.getAddress().size() > 0) {
                Address address = ((ArrayList<Address>) mPatient.getAddress()).get(0);
                ((TextView) findViewById(R.id.prof_addr_tv)).setText(address.getStreet1() + ","
                        + (TextUtils.isEmpty(address.getStreet2()) ? "" : address.getStreet2() + ",")
                        + address.getCity() + "," + address.getState() + "," + address.getZip() + ","
                        + address.getCountry());
            }

        } catch (Exception e) {
            Log.e("isUserLogin", "", e);

        }
        //Code to get and display insurance info

        new GetInsuranceInfo().execute(mPatient.getMRNId());
    }

    /* mProgressDialog = new ProgressDialog(this);
     mProgressDialog.setCancelable(false);*/
}

From source file:azkaban.execapp.AzkabanExecutorServer.java

/**
 * Azkaban using Jetty/*from   ww w . ja v a2s  . com*/
 *
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws Exception {
    // Redirect all std out and err messages into log4j
    StdOutErrRedirect.redirectOutAndErrToLog();

    logger.info("Starting Jetty Azkaban Executor...");
    Props azkabanSettings = AzkabanServer.loadProps(args);

    if (azkabanSettings == null) {
        logger.error("Azkaban Properties not loaded.");
        logger.error("Exiting Azkaban Executor Server...");
        return;
    }

    // Setup time zone
    if (azkabanSettings.containsKey(DEFAULT_TIMEZONE_ID)) {
        String timezone = azkabanSettings.getString(DEFAULT_TIMEZONE_ID);
        System.setProperty("user.timezone", timezone);
        TimeZone.setDefault(TimeZone.getTimeZone(timezone));
        DateTimeZone.setDefault(DateTimeZone.forID(timezone));

        logger.info("Setting timezone to " + timezone);
    }

    app = new AzkabanExecutorServer(azkabanSettings);

    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            try {
                logTopMemoryConsumers();
            } catch (Exception e) {
                logger.info(("Exception when logging top memory consumers"), e);
            }

            String host = app.getHost();
            int port = app.getPort();
            try {
                logger.info(String.format("Removing executor(host: %s, port: %s) entry from database...", host,
                        port));
                app.getExecutorLoader().removeExecutor(host, port);
            } catch (ExecutorManagerException ex) {
                logger.error(String.format("Exception when removing executor(host: %s, port: %s)", host, port),
                        ex);
            }

            logger.warn("Shutting down executor...");
            try {
                app.shutdownNow();
            } catch (Exception e) {
                logger.error("Error while shutting down http server.", e);
            }
        }

        public void logTopMemoryConsumers() throws Exception, IOException {
            if (new File("/bin/bash").exists() && new File("/bin/ps").exists()
                    && new File("/usr/bin/head").exists()) {
                logger.info("logging top memeory consumer");

                java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder("/bin/bash", "-c",
                        "/bin/ps aux --sort -rss | /usr/bin/head");
                Process p = processBuilder.start();
                p.waitFor();

                InputStream is = p.getInputStream();
                java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is));
                String line = null;
                while ((line = reader.readLine()) != null) {
                    logger.info(line);
                }
                is.close();
            }
        }
    });
}

From source file:com.qtplaf.library.util.Calendar.java

/**
 * Returns a GTM calendar.//from w  w w . j a va 2s. co  m
 *
 * @param time The time in millis.
 * @return The calendar.
 */
public static Calendar getGTMCalendar(long time) {
    Calendar calendar = new Calendar(time);
    calendar.setTimeZone(TimeZone.getTimeZone("GTM"));
    return calendar;
}

From source file:com.eluup.flume.sink.elasticsearch.TimeBasedIndexNameBuilder.java

public void configure(Context context) {
    String dateFormatString = context.getString(DATE_FORMAT);
    String timeZoneString = context.getString(TIME_ZONE);
    if (StringUtils.isBlank(dateFormatString)) {
        dateFormatString = DEFAULT_DATE_FORMAT;
    }/*from www .  j av  a 2 s.c  o m*/
    if (StringUtils.isBlank(timeZoneString)) {
        timeZoneString = DEFAULT_TIME_ZONE;
    }
    fastDateFormat = FastDateFormat.getInstance(dateFormatString, TimeZone.getTimeZone(timeZoneString));
    indexPrefix = context.getString(ElasticSearchSinkConstants.INDEX_NAME);
}

From source file:net.networksaremadeofstring.cyllell.Authentication.java

private String GetTimeStamp() {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.UK);
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
    return sdf.format(new Date());
}

From source file:com.profesorfalken.payzen.webservices.sdk.handler.soap.HeaderHandler.java

/**
 * Takes the outgoing SOAP message and modifies it adding the header 
 * information// w w  w.j  ava  2  s.c  o  m
 * 
 * @param smc SOAP message context
 * @return 
 */
@Override
public boolean handleMessage(SOAPMessageContext smc) {

    Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    if (Boolean.TRUE.equals(outboundProperty)) {

        SOAPMessage message = smc.getMessage();

        try {
            SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();

            //Creates header into SOAP envelope
            SOAPHeader header = envelope.getHeader();
            if (header == null) {
                header = envelope.addHeader();
            }

            // Add shopId
            addHeaderField(header, "shopId", this.shopId);

            // Timestamp
            TimeZone tz = TimeZone.getTimeZone("UTC");
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            df.setTimeZone(tz);
            String nowAsISO = df.format(new Date());
            addHeaderField(header, "timestamp", nowAsISO);

            // Mode
            addHeaderField(header, "mode", this.mode);

            // Add requestId
            String requestId = UUID.randomUUID().toString();
            addHeaderField(header, "requestId", requestId);

            // Authentication token
            String tokenString = requestId + nowAsISO;
            addHeaderField(header, "authToken", sign(tokenString, shopKey));

        } catch (SOAPException e) {
            logger.error("Error sending header", e);
        }
    }

    return outboundProperty;

}

From source file:android.framework.org.apache.harmony.security_custom.asn1.ASN1UTCTime.java

@Override
public void setEncodingContent(BerOutputStream out) {
    SimpleDateFormat sdf = new SimpleDateFormat(UTC_PATTERN);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    out.content = sdf.format(out.content).getBytes(Charsets.UTF_8);
    out.length = ((byte[]) out.content).length;
}

From source file:com.whizzosoftware.hobson.scheduler.ical.ICalTaskTest.java

@Test
public void testGetConditions() throws Exception {
    TimeZone tz = TimeZone.getTimeZone("GMT");
    VEvent event = new VEvent(new DateTime(DateHelper.getTime(tz, 2001, 4, 13, 0, 0, 0)), "task1");
    event.getProperties().add(new UidGenerator("1").generateUid());
    event.getProperties().add(new Comment(
            "[{'pluginId':'com.whizzosoftware.hobson.server-api','actionId':'log','name':'My Action','properties':{'message':'foo'}}]"));
    Recur recur = new Recur("FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13");
    event.getProperties().add(new RRule(recur));

    ICalTask task = new ICalTask(null, "", event, null);

    Collection<Map<String, Object>> conditions = task.getConditions();
    assertEquals(1, conditions.size());// w  ww. j  a v a 2s .  c o m
    Map<String, Object> map = conditions.iterator().next();
    assertEquals(2, map.size());
    assertEquals("20010412T180000", map.get("start"));
    assertEquals("FREQ=MONTHLY;BYMONTHDAY=13;BYDAY=FR", map.get("recurrence"));
}