List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:fr.certu.chouette.validation.checkpoint.AbstractValidation.java
protected long getTimeInSeconds(Time time) { TimeZone tz = TimeZone.getDefault(); long millis = 0; millis = time.getTime() + tz.getRawOffset(); return millis / 1000; }
From source file:com.akop.bach.parser.XboxLiveParser.java
@Override protected void initRequest(HttpUriRequest request) { super.initRequest(request); // Set the timezone cookie TimeZone tz = TimeZone.getDefault(); int utcOffsetMinutes = tz.getOffset(System.currentTimeMillis()) / (1000 * 60); BasicClientCookie cookie = new BasicClientCookie("UtcOffsetMinutes", String.valueOf(utcOffsetMinutes)); cookie.setPath("/"); cookie.setDomain(".xbox.com"); mHttpClient.getCookieStore().addCookie(cookie); }
From source file:br.edu.ufcg.supervisor.SupervisorInterface.java
public String getTimeZoneID() { TimeZone tz = TimeZone.getDefault(); return (tz.getID()); }
From source file:MimeUtil.java
/** * Formats the specified date into a RFC 822 date-time string. * // www . j ava 2 s. c o m * @param date * date to be formatted into a string. * @param zone * the time zone to use or <code>null</code> to use the default * time zone. * @return the formatted time string. */ public static String formatDate(Date date, TimeZone zone) { DateFormat df = RFC822_DATE_FORMAT.get(); if (zone == null) { df.setTimeZone(TimeZone.getDefault()); } else { df.setTimeZone(zone); } return df.format(date); }
From source file:com.jaspersoft.jasperserver.war.common.JasperServerUtil.java
protected static TimeZone getTimezone(String timeZoneId) { TimeZone timeZone;// w w w . j a v a 2 s . c o m if (timeZoneId == null) { timeZone = TimeZone.getDefault(); } else { timeZone = TimeZone.getTimeZone(timeZoneId); } return timeZone; }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
public void handleExportTransactions() { // Create CSV file from transactions final File file = new File(Constants.Files.EXTERNAL_WALLET_BACKUP_DIR, Constants.Files.TX_EXPORT_NAME + "-" + getFileDate() + ".csv"); try {/*from www .j a va 2s. com*/ final BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append("Date,Label,Amount (" + MonetaryFormat.CODE_PPC + "),Fee (" + MonetaryFormat.CODE_PPC + "),Address,Transaction Hash,Confirmations\n"); if (txListAdapter == null || txListAdapter.transactions.isEmpty()) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed"); return; } final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm z"); dateFormat.setTimeZone(TimeZone.getDefault()); for (Transaction tx : txListAdapter.transactions) { TransactionsListAdapter.TransactionCacheEntry txCache = txListAdapter.getTxCache(tx); String memo = tx.getMemo() == null ? "" : StringEscapeUtils.escapeCsv(tx.getMemo()); String fee = tx.getFee() == null ? "" : tx.getFee().toPlainString(); String address = txCache.address == null ? getString(R.string.export_transactions_unknown) : txCache.address.toString(); writer.append(dateFormat.format(tx.getUpdateTime()) + ","); writer.append(memo + ","); writer.append(txCache.value.toPlainString() + ","); writer.append(fee + ","); writer.append(address + ","); writer.append(tx.getHash().toString() + ","); writer.append(tx.getConfidence().getDepthInBlocks() + "\n"); } writer.flush(); writer.close(); } catch (IOException x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); return; } final DialogBuilder dialog = new DialogBuilder(this); dialog.setMessage(Html.fromHtml(getString(R.string.export_transactions_dialog_success, file))); dialog.setPositiveButton(WholeStringBuilder.bold(getString(R.string.export_keys_dialog_button_archive)), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_transactions_mail_subject)); intent.putExtra(Intent.EXTRA_TEXT, makeEmailText(getString(R.string.export_transactions_mail_text))); intent.setType(Constants.MIMETYPE_TX_EXPORT); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); try { startActivity(Intent.createChooser(intent, getString(R.string.export_transactions_mail_intent_chooser))); log.info("invoked chooser for exporting transactions"); } catch (final Exception x) { longToast(R.string.export_transactions_mail_intent_failed); log.error("exporting transactions failed", x); } } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); }
From source file:lt.bsprendimai.ddesk.UserHandler.java
public String getTimeZone() { return TimeZone.getDefault().getID(); }
From source file:com.whizzosoftware.hobson.scheduler.ical.ICalTaskProviderTest.java
@Test public void testDayResetWithSolarOffsetTask() throws Exception { TimeZone tz = TimeZone.getDefault(); // an event that runs every day at midnight String ical = "BEGIN:VCALENDAR\n" + "VERSION:2.0\n" + "BEGIN:VEVENT\n" + "UID:15dee4fe-a841-4cf6-8d7f-76c3ad5492b1\n" + "DTSTART:20140701T000000\n" + "RRULE:FREQ=DAILY\n" + "X-SUN-OFFSET:SS30\n" + "SUMMARY:My Task\n" + "COMMENT:[{'pluginId':'com.whizzosoftware.hobson.server-api','actionId':'log','name':'My Action','properties':{'message':'Test'}}]\n" + "END:VEVENT\n" + "END:VCALENDAR"; // start the scheduler after the task should have run MockScheduledTaskExecutor executor = new MockScheduledTaskExecutor(); MockActionManager actionManager = new MockActionManager(); ICalTaskProvider s = new ICalTaskProvider("pluginId", null, null, tz); s.setLatitudeLongitude(39.3722, -104.8561); s.setScheduleExecutor(executor);/*from w w w .j a va2 s . c om*/ s.setActionManager(actionManager); s.loadICSStream(new ByteArrayInputStream(ical.getBytes()), DateHelper.getTime(tz, 2014, 7, 1, 22, 0, 0)); // verify task was not scheduled or executed assertEquals(1, s.getTasks().size()); ICalTask t = (ICalTask) s.getTasks().iterator().next(); assertFalse(executor.isTaskScheduled(t)); assertEquals(0, actionManager.getLogCalls()); assertNull(t.getProperties().getProperty(ICalTask.PROP_NEXT_RUN_TIME)); // start a new day at midnight s.resetForNewDay(DateHelper.getTime(tz, 2014, 7, 2, 0, 0, 0)); // verify task was scheduled at appropriate time and task did not execute assertEquals(1, s.getTasks().size()); t = (ICalTask) s.getTasks().iterator().next(); assertTrue(executor.isTaskScheduled(t)); assertEquals(75600000, (long) executor.getDelayForTask(t)); assertEquals(0, actionManager.getLogCalls()); assertEquals(1404356400000l, t.getProperties().get(ICalTask.PROP_NEXT_RUN_TIME)); assertTrue((boolean) t.getProperties().get(ICalTask.PROP_SCHEDULED)); }
From source file:com.redhat.rhn.frontend.struts.StrutsDelegate.java
private DatePicker getDatePicker(String name, int yearDirection) { Context ctx = Context.getCurrentContext(); if (ctx == null) { return new DatePicker(name, TimeZone.getDefault(), Locale.getDefault(), yearDirection); }/*from w w w .j a va 2 s. c o m*/ return new DatePicker(name, ctx.getTimezone(), ctx.getLocale(), yearDirection); }
From source file:com.sshdemo.common.schedule.generate.quartz.JobsQuartzScheduler.java
protected Date translateFromTriggerTimeZone(JobTrigger jobTrigger, Date date) throws BaseException { if (date != null) { TimeZone tz = getTriggerTimeZone(jobTrigger); if (tz != null) { date = DateBuilder.translateTime(date, TimeZone.getDefault(), tz); }/*w w w .ja v a2s . c o m*/ } return date; }