Example usage for java.util TimeZone setDefault

List of usage examples for java.util TimeZone setDefault

Introduction

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

Prototype

public static void setDefault(TimeZone zone) 

Source Link

Document

Sets the TimeZone that is returned by the getDefault method.

Usage

From source file:hudson.plugins.timestamper.TimestampFormatterTest.java

/**
 *///w  w  w . j a v a  2  s  .com
@Test
public void testMarkupElapsedTimeWithDifferentTimeZone() {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    assertThat(markup("line").toString(true), is(span(timestampStringInDifferentTimezone) + "line"));
}

From source file:org.wso2.ei.businessprocess.utils.processcleanup.CleanupExecutor.java

/**
 * main method//from  w  ww  .  j  a v a2 s. c  om
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    if (System.getProperty("carbon.components.dir.path") != null) {
        addJarFileUrls(new File(System.getProperty("carbon.components.dir.path")));
    }

    initializeDBConnection();
    query = new DBQuery(databaseURL, bpsHome);
    TimeZone.setDefault(TimeZone.getTimeZone(getProperty(CleanupConstants.TIME_ZONE)));
    System.out.println("\n=============ATTENTION=================\n"
            + "This tool deletes selected process versions and optionally all corresponding process instances.\n"
            + "Hence take backups of DB before executing this tool.\n"
            + "Also read configuration information from the docs before running the tool.\n"
            + "=======================================");

    System.out.println("\nInsert option number to list non-active BPEL packages");
    System.out.println("1. List All");
    System.out.println("2. Search and List by Process Name");
    System.out.println("3. Exit");

    int userInput[] = getValidUserInput(1, 3, CleanupConstants.ENTER_OPTION_NUMBER);
    String name = null;
    switch (userInput[0]) {
    case 3:
        System.exit(0);
        break;
    case 2:
        System.out.println("Please Enter Process Name:");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        name = br.readLine().trim();
    default:
        System.out.println("Initialize JDBC Connection\n");
        try {
            //listing out the deletable process list in the console
            System.out.println("List of Non-Active BPEL Packages\n");
            System.out.println(String.format(" %-9s | %s", "Option #", "Package Name"));
            System.out.println("==========================================");
            map = getDeletablePackageList(name);
            String[] list = map.keySet().toArray(new String[] {});
            int deleteAllOption = list.length + 1;

            switch (list.length) {
            case 0:
                System.out.println("*** No Packages Found ***");
                System.out.println("==========================================");
                break;
            case 1:
                System.out.println("==========================================");
                break;
            default:
                System.out.println("==========================================");
                String id = String.format("%9d", deleteAllOption);
                System.out.println(String.format("%-10s | %s", id, "Delete All"));
                break;
            }
            String id = String.format("%9d", 0);
            System.out.println(String.format("%-10s | %s", id, "Exit"));

            //Get user input with multiple packages to delete at once
            int options[] = getValidUserInput(0, deleteAllOption, CleanupConstants.OPTION_NUMBERS_TO_DELETE);

            if (options[0] == 0) {
                //if entered 0 system exits
                System.exit(0);
            } else if (options[0] == deleteAllOption) {
                //Delete all option
                for (String packageName : list) {
                    deletePackages(packageName);
                }
            } else {
                //Delete several packages
                for (int op : options) {
                    deletePackages(list[op - 1]);
                }
            }

        } catch (Exception e) {
            String errMsg = "Process deletion exception.";
            log.error(errMsg, e);
        }
        break;
    }
}

From source file:io.cslinmiso.line.utils.Utility.java

public static Date getTaipeiDateTime() {
    TimeZone tz = TimeZone.getTimeZone("Asia/Taipei");
    TimeZone.setDefault(tz);
    return new Date();
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SessionScheduleItemsFragment.java

protected void setupDay(ViewGroup rootView) {
    final long currentTime = getArguments().getLong("currentTime");

    mDay = new Day();

    // Setup data
    for (int i = UIUtils.NUMBER_DAYS; i > 0; i--) {
        if (currentTime >= UIUtils.START_DAYS_IN_MILLIS[i - 1]) {
            mDay.index = (i - 1);/* w  w w  .jav a2  s  .co  m*/
            break;
        }
    }
    mDay.timeStart = UIUtils.START_DAYS_IN_MILLIS[mDay.index];
    mDay.timeEnd = mDay.timeStart + DateUtils.DAY_IN_MILLIS;
    mDay.loaderUri = CfpContract.Sessions.buildSessionsBetweenDirUri(mDay.timeStart, mDay.timeEnd);

    // Setup views
    mDay.rootView = rootView;

    mDay.scrollView = (ObservableScrollView) mDay.rootView.findViewById(R.id.schedule_items_scroll);

    mDay.scheduleItemsView = (ScheduleItemsLayout) mDay.rootView.findViewById(R.id.schedule_items);
    mDay.nowView = mDay.rootView.findViewById(R.id.schedule_items_now);

    // mDay.blocksView.setDrawingCacheEnabled(true);
    // mDay.blocksView.setAlwaysDrawnWithCacheEnabled(true);

    TimeZone.setDefault(UIUtils.CONFERENCE_TIME_ZONE);
}

From source file:hudson.plugins.timestamper.TimestampFormatterTest.java

/**
 *//*from w ww  .  j a v a  2 s.c  o  m*/
@Test
public void testMarkupElapsedTimeWithDifferentTimeZoneAfterSerialization() {
    serialize = true;
    TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    assertThat(markup("line").toString(true), is(span(timestampStringInDifferentTimezone) + "line"));
}

From source file:hudson.plugins.timestamper.format.TimestampFormatterImplTest.java

/**
 *//* w ww.  j a  va 2  s  . co m*/
@Test
public void testMarkupElapsedTimeWithDifferentTimeZone() {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
    assertThat(markup("line").toString(true), is(prefixInDifferentTimezone + "line"));
}

From source file:org.apache.kylin.rest.service.JobService.java

@SuppressWarnings("unchecked")
@Override/*from   w  ww. j a v a2 s. co m*/
public void afterPropertiesSet() throws Exception {

    String timeZone = getConfig().getTimeZone();
    TimeZone tzone = TimeZone.getTimeZone(timeZone);
    TimeZone.setDefault(tzone);

    final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    final Scheduler<AbstractExecutable> scheduler = (Scheduler<AbstractExecutable>) SchedulerFactory
            .scheduler(kylinConfig.getSchedulerType());

    jobLock = (JobLock) ClassUtil.newInstance(kylinConfig.getJobControllerLock());

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                scheduler.init(new JobEngineConfig(kylinConfig), jobLock);
                if (!scheduler.hasStarted()) {
                    logger.info("scheduler has not been started");
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }).start();

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                scheduler.shutdown();
            } catch (SchedulerException e) {
                logger.error("error occurred to shutdown scheduler", e);
            }
        }
    }));
}

From source file:org.pentaho.di.junit.rules.RestorePDIEnvironment.java

@Override
protected void before() throws Throwable {
    originalProperties = System.getProperties();
    System.setProperties(copyOf(originalProperties));

    originalLocale = Locale.getDefault();
    originalFormatLocale = Locale.getDefault(Locale.Category.FORMAT);
    originalTimezone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    Locale.setDefault(Locale.US);
    Locale.setDefault(Locale.Category.FORMAT, Locale.US);
    LanguageChoice.getInstance().setDefaultLocale(Locale.US);

    tmpKettleHome = Files.createTempDirectory(Long.toString(System.nanoTime()));
    System.setProperty("file.encoding", "UTF-8");
    System.setProperty("user.timezone", "UTC");
    System.setProperty("KETTLE_HOME", tmpKettleHome.toString());
    System.setProperty(Const.KETTLE_DISABLE_CONSOLE_LOGGING, "Y");
    System.clearProperty(Const.VFS_USER_DIR_IS_ROOT);
    System.clearProperty(Const.KETTLE_LENIENT_STRING_TO_NUMBER_CONVERSION);
    System.clearProperty(Const.KETTLE_COMPATIBILITY_DB_IGNORE_TIMEZONE);
    System.clearProperty(Const.KETTLE_DEFAULT_INTEGER_FORMAT);
    System.clearProperty(Const.KETTLE_DEFAULT_NUMBER_FORMAT);
    System.clearProperty(Const.KETTLE_DEFAULT_BIGNUMBER_FORMAT);
    System.clearProperty(Const.KETTLE_DEFAULT_DATE_FORMAT);
    System.clearProperty(Const.KETTLE_DEFAULT_TIMESTAMP_FORMAT);
    System.clearProperty(Const.KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL);

    defaultInit();//from w  ww .j ava  2s.c o m
}

From source file:com.oltpbenchmark.util.ResultUploader.java

public void writeSummary(PrintStream os) {
    Map<String, Object> summaryMap = new TreeMap<String, Object>();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    Date now = new Date();
    summaryMap.put("Current Timestamp (milliseconds)", now.getTime());
    summaryMap.put("DBMS Type", dbType);
    summaryMap.put("DBMS Version", collector.collectVersion());
    summaryMap.put("Benchmark Type", benchType);
    summaryMap.put("Latency Distribution", results.latencyDistribution.toMap());
    summaryMap.put("Throughput (requests/second)", results.getRequestsPerSecond());
    for (String field : BENCHMARK_KEY_FIELD) {
        summaryMap.put(field, expConf.getString(field));
    }// ww  w.j a v  a 2  s .  c om
    os.println(JSONUtil.format(JSONUtil.toJSONString(summaryMap)));
}

From source file:com.google.android.apps.iosched.util.UIUtils.java

/**
 * Format and return the given {@link Blocks} values using
 * {@link #CONFERENCE_TIME_ZONE}.//from w w  w.  j a  v a 2 s .c  o  m
 */
public static String formatBlockTimeString(long blockStart, long blockEnd, Context context) {
    TimeZone.setDefault(CONFERENCE_TIME_ZONE);

    // NOTE: There is an efficient version of formatDateRange in Eclair and
    // beyond that allows you to recycle a StringBuilder.
    return DateUtils.formatDateRange(context, blockStart, blockEnd, TIME_FLAGS);
}