List of usage examples for java.util Locale UK
Locale UK
To view the source code for java.util Locale UK.
Click Source Link
From source file:damo.three.ie.util.HtmlUtilities.java
/** * Parses the My3 account usage page to nicer JSON format. * * @param pageContent Page content as HTML. * @return Usage information stripped out and formatted as JSON. * @throws JSONException// w w w . ja v a 2 s.c o m */ public static JSONArray parseUsageAsJSONArray(String pageContent) throws JSONException { // The HTML on prepay is pig-ugly, so we will use JSoup to // clean and parse it. Document doc = Jsoup.parse(pageContent); HtmlUtilities.removeComments(doc); Elements elements = doc.getElementsByTag("table"); JSONArray jsonArray = new JSONArray(); // three don't have a sub label for the 3-to-3 calls, which is not consistent with other items. // .. feck them! boolean three2threeCallsBug = false; for (Element element : elements) { for (Element subelement : element.select("tbody > tr")) { if ((subelement.text().contains("3 to 3 Calls")) && (subelement.text().contains("Valid until"))) { three2threeCallsBug = true; } Elements subsubelements = subelement.select("td"); if (subsubelements.size() == 3) { // skip the "total" entries if (subsubelements.select("td").get(0).text().contains("Total")) { continue; } JSONObject currentItem = new JSONObject(); if (three2threeCallsBug) { currentItem.put("item", "3 to 3 Calls"); } else { // Get rid of that "non-breaking space" character if it exists String titleToClean = subsubelements.select("td").get(0).text().replace("\u00a0", "") .trim(); currentItem.put("item", titleToClean); } /** * Check if date contains "Today", if so, change it to a date. * Otherwise we will never know when usage ends, unless user refreshes, As 'today' * is 'today', tomorrow.. see! */ String value1 = subsubelements.select("td").get(1).text(); if (value1.equals("Today")) { DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yy").withLocale(Locale.UK); DateTime dt = new DateTime(); // current datetime value1 = "Expires " + formatter.print(dt); } currentItem.put("value1", value1); currentItem.put("value2", subsubelements.select("td").get(2).text()); // Out of Bundle charges have an extra property if (currentItem.getString("item").startsWith("Internet")) { Pattern p1 = Pattern.compile(Constants.OUT_OF_BUNDLE_REGEX, Pattern.DOTALL); Matcher m1 = p1.matcher(pageContent); StringBuilder cleanedDate = new StringBuilder(); if (m1.matches()) { cleanedDate.append(m1.group(1)); cleanedDate.append(' '); cleanedDate.append(m1.group(2)); cleanedDate.append(' '); cleanedDate.append(m1.group(3)); currentItem.put("value3", cleanedDate.toString()); } } jsonArray.put(currentItem); } } // reset the 3-to-3 call bug flag for next Element if (three2threeCallsBug) { three2threeCallsBug = false; } } return jsonArray; }
From source file:org.apache.james.protocols.smtp.AbstractStartTlsSMTPServerTest.java
@Test public void testStartTLS() throws Exception { InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort()); ProtocolServer server = null;/*from w ww.j a v a2 s . c o m*/ try { server = createServer(createProtocol(new ProtocolHandler[0]), address, Encryption.createStartTls(BogusSslContextFactory.getServerContext())); server.bind(); SMTPSClient client = createClient(); client.connect(address.getAddress().getHostAddress(), address.getPort()); assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode())); client.sendCommand("EHLO localhost"); assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode())); boolean startTLSAnnounced = false; for (String reply : client.getReplyStrings()) { if (reply.toUpperCase(Locale.UK).endsWith("STARTTLS")) { startTLSAnnounced = true; break; } } assertTrue(startTLSAnnounced); assertTrue(client.execTLS()); // TODO: Add back once commons-net 3.1.0 was released. // See: NET-421 // //client.quit(); //assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode())); client.disconnect(); } finally { if (server != null) { server.unbind(); } } }
From source file:org.jfree.data.time.junit.DayTest.java
/** * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L). * Use this to check the day constructor. *//*from www . java 2s. co m*/ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Calendar c = new GregorianCalendar(zone); Locale locale = Locale.UK; Day d1 = new Day(new Date(1078099199999L), zone, locale); Day d2 = new Day(new Date(1078099200000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078099199999L, d1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078099200000L, d2.getFirstMillisecond(c)); }
From source file:com.sfs.whichdoctor.dao.ItemDAOImpl.java
/** * Used to get a TreeMap of ItemBean details for a specified GUID number. * * @param guid the guid//from w ww. j ava2 s . co m * @param fullResults the full results * @param itemTypeVal the item type value * @param groupClassVal the group class value * @param object2GUID the object2 guid * @param startDate the start date * @param endDate the end date * * @return the tree map< string, item bean> * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final TreeMap<String, ItemBean> load(final int guid, final boolean fullResults, final String itemTypeVal, final String groupClassVal, final int object2GUID, final String startDate, final String endDate) throws WhichDoctorDaoException { TreeMap<String, ItemBean> items = new TreeMap<String, ItemBean>(); String itemType = "Group"; String groupClass = "Members"; if (itemTypeVal != null) { itemType = itemTypeVal; } if (groupClass != null) { groupClass = groupClassVal; } if (StringUtils.equalsIgnoreCase(itemType, "Employer") || StringUtils.equalsIgnoreCase(itemType, "Employee")) { itemType = "Employment"; } java.util.Date dtStartDate = null; java.util.Date dtEndDate = null; DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.UK); try { dtStartDate = df.parse(startDate); } catch (Exception e) { dataLogger.debug("Error parsing start date: " + e.getMessage()); } try { dtEndDate = df.parse(endDate); } catch (Exception e) { dataLogger.debug("Error parsing end date: " + e.getMessage()); } if (dtStartDate != null && dtEndDate != null && dtStartDate.compareTo(dtEndDate) > 0) { /* Start date is greater than end date, switch around */ java.util.Date tempStartDate = dtStartDate; dtStartDate = dtEndDate; dtEndDate = tempStartDate; } StringBuffer loadItems = new StringBuffer(); ArrayList<Object> parameters = new ArrayList<Object>(); parameters.add(guid); parameters.add(itemType); loadItems.append(getLoadSQL(groupClass)); if (StringUtils.equalsIgnoreCase(groupClass, "Employers")) { loadItems.append(" AND items.Object2GUID = ? AND itemtype.Class = ?"); } else { loadItems.append(" AND items.Object1GUID = ? AND itemtype.Class = ?"); } if (object2GUID > 0) { loadItems.append(" AND items.Object2GUID = ?"); parameters.add(object2GUID); } dataLogger.info("Items for GUID: " + guid + " requested"); Collection<ItemBean> itemCollection = new ArrayList<ItemBean>(); try { itemCollection = this.getJdbcTemplateReader().query(loadItems.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadItem(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } for (ItemBean item : itemCollection) { if (item.display(dtStartDate, dtEndDate)) { items.put(item.getOrderIndex(), item); } } return items; }
From source file:it.txt.access.capability.revocation.wizard.panel.PanelRevocationData.java
/** Creates new form WelcomePanel */ public PanelRevocationData(String title, Frame container, ControllerPanelRevocationData cpatp) { this.title = title; initComponents();/* w w w. j a va 2s . c om*/ checkEditableTextBox(textbox_rev_issuer); checkEditableTextBox(textbox_rev_reason); checkFormattedTextBoxIsEmpty(textbox_revoked_since_datetime); checkFormattedTextBoxIsEmpty(textbox_revoked_since_time); checkEditableTextBox(textbox_notification_email); checkEditableTextBox(textbox_revoked_aucap_issuer); checkFormattedTextBoxIsEmpty(textbox_revoked_aucap_issue_datetime); checkFormattedTextBoxIsEmpty(textbox_revoked_aucap_issue_time); checkEditableTextBox(textbox_revoked_aucap_id); checkEditableTextBox(textbox_revoked_aucap_version); myContainer = container; dialog_revoked_since_date = new DateChooserDialog("Starting revocation date", myContainer, true); dialog_revoked_since_date.setLocale(Locale.UK); dialog_revoked_aucap_issue_date = new DateChooserDialog("Revoked capability issue date", myContainer, true); dialog_revoked_aucap_issue_date.setLocale(Locale.UK); filterAssertion = new FilterXML("Access Rights Capability"); auCapTokenChooser = new JFileChooser(); auCapTokenChooser.setFileFilter(filterAssertion); auCapTokenChooser.setMultiSelectionEnabled(false); //init file chooser if (currentAuCapTokenPath == null) { auCapTokenChooser.setCurrentDirectory(new File(".")); } else { auCapTokenChooser.setCurrentDirectory(currentAuCapTokenPath); } }
From source file:org.jfree.data.time.junit.MonthTest.java
/** * In GMT, the end of Feb 2000 is java.util.Date(951,868,799,999L). Use * this to check the Month constructor./*from w w w . jav a 2 s. c o m*/ */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Calendar c = new GregorianCalendar(zone); Locale locale = Locale.UK; Month m1 = new Month(new Date(951868799999L), zone, locale); Month m2 = new Month(new Date(951868800000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, m1.getMonth()); assertEquals(951868799999L, m1.getLastMillisecond(c)); assertEquals(MonthConstants.MARCH, m2.getMonth()); assertEquals(951868800000L, m2.getFirstMillisecond(c)); }
From source file:org.powertac.producer.pvfarm.IrradianceModelTest.java
@Test public void testIrradianceModel() throws IOException { File file = new File("data/dataIrradianceModel.txt"); file.createNewFile();/*from w w w. j a va 2s. co m*/ PrintWriter pw = new PrintWriter(new File("data/dataIrradianceModel.txt")); for (double g = 0; g < 24; g += 0.1) { double sunAltitude = SolarModel.getSunAltitudeAngle(g, 45, 180); if (sunAltitude >= 0) { double airmass = IrradianceModel.getAirMass(sunAltitude); double direct = IrradianceModel.getDirectIrradiance(sunAltitude, 1367.7, IrradianceModel.getT0(airmass, 3), IrradianceModel.getTr(airmass), IrradianceModel.getaw(airmass, 0.1, 300), 0.98); double diffuse = IrradianceModel.getDiffuseIrradiance(sunAltitude, 1367.7, IrradianceModel.getT0(airmass, 3), IrradianceModel.getTr(airmass), IrradianceModel.getaw(airmass, 0.1, 300), 0.98, 0.98, IrradianceModel.getf(sunAltitude)); assertTrue(direct >= 0 && diffuse >= 0); pw.printf(Locale.UK, "%f,%f,%f%n", g, direct, diffuse); } } pw.close(); }
From source file:baasi.hackathon.sja.TalkActivity.java
/** * ?? ???//from w w w . j a v a 2s . co m * @param word String */ private void startTalk(final String word) { speech = new TextToSpeech(getBaseContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status != TextToSpeech.ERROR) { speech.setLanguage(Locale.UK); speech.speak(word, TextToSpeech.QUEUE_FLUSH, null); } } }); }
From source file:org.mifos.config.Localization.java
private synchronized void setLocaleMap() { if (LOCALE_MAP.isEmpty()) { LOCALE_MAP.put((short) 1, Locale.UK); // These were the options in personnel language list (pre Mifos 2.2) LOCALE_MAP.put((short) 2, new Locale("is", "IS")); // Icelandic LOCALE_MAP.put((short) 3, SPANISH); // Spanish LOCALE_MAP.put((short) 4, Locale.FRANCE); // French LOCALE_MAP.put((short) 5, Locale.SIMPLIFIED_CHINESE); // Chinese LOCALE_MAP.put((short) 6, new Locale("sw", "KE")); // Swahili LOCALE_MAP.put((short) 7, new Locale("ar", "DZ")); // Arabic LOCALE_MAP.put((short) 8, new Locale("pt", "AO")); // Portuguese LOCALE_MAP.put((short) 9, new Locale("km", "KH")); // Khmer LOCALE_MAP.put((short) 10, new Locale("lo", "LA")); // Lola LOCALE_MAP.put((short) 11, new Locale("hu", "HU")); // Hungarian LOCALE_MAP.put((short) 12, new Locale("te", "IN")); // Tegulu LOCALE_MAP.put((short) 13, new Locale("hi", "IN")); // Hindi LOCALE_MAP.put((short) 14, Locale.GERMAN); LOCALE_MAP.put((short) 15, new Locale("ru")); // Georgian LOCALE_MAP.put((short) 16, new Locale("ka")); // Russian }//www . jav a 2 s.co m }
From source file:userinterface.graph.AxisSettings.java
public AxisSettings(String name, boolean isDomain, Graph graph) { this.name = name; this.isDomain = isDomain; this.graph = graph; this.chart = graph.getChart(); this.plot = chart.getXYPlot(); this.axis = (isDomain) ? this.plot.getDomainAxis() : this.plot.getRangeAxis(); this.valuesFormatter = NumberFormat.getInstance(Locale.UK); if (this.valuesFormatter instanceof DecimalFormat) ((DecimalFormat) this.valuesFormatter) .applyPattern("###,###,###,###,###,###,###,###.########################"); /* Initialise all the settings. */ heading = new SingleLineStringSetting("heading", name, "The heading for this axis", this, true); headingFont = new FontColorSetting("heading font", new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black), "The font for this axis' heading.", this, true); numberFont = new FontColorSetting("numbering font", new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black), "The font used to number the axis.", this, true); showGrid = new BooleanSetting("show gridlines", new Boolean(true), "Should the gridlines be visible", this, true);//from w w w.ja v a2 s . c o m gridColour = new ColorSetting("gridline colour", new Color(204, 204, 204), "The colour of the gridlines", this, true); String[] logarithmicChoices = { "Normal", "Logarithmic" }; scaleType = new ChoiceSetting("scale type", logarithmicChoices, logarithmicChoices[0], "Should the scale be normal, or logarithmic", this, true); autoScale = new BooleanSetting("auto-scale", new Boolean(true), "When set to true, all minimum values, maximum values, grid intervals, maximum logarithmic powers and minimum logarithmic powers are automatically set and maintained when the data changes.", this, true); minValue = new DoubleSetting("minimum value", new Double(0.0), "The minimum value for the axis", this, true); maxValue = new DoubleSetting("maximum value", new Double(1.0), "The maximum value for the axis", this, true); gridInterval = new DoubleSetting("gridline interval", new Double(0.2), "The interval between gridlines", this, false, new RangeConstraint(0, Double.POSITIVE_INFINITY, false, true)); logBase = new DoubleSetting("log base", new Double(10), "The base for the logarithmic scale", this, false, new RangeConstraint("1,")); minimumPower = new DoubleSetting("minimum power", new Double("0.0"), "The minimum logarithmic power that should be displayed on the scale", this, true); maximumPower = new DoubleSetting("maximum power", new Double("1.0"), "The maximum logarithmic power that should be displayed on the scale", this, true); String[] logStyleChoices = { "Values", "Base and exponent" }; logStyle = new ChoiceSetting("logarithmic number style", logStyleChoices, logStyleChoices[1], "Should the style of the logarithmic scale show the actual values, or the base with the exponent.", this, false); /* Add constraints. */ minValue.addConstraint(new NumericConstraint() { public void checkValueDouble(double d) throws SettingException { if (activated && d >= maxValue.getDoubleValue()) throw new SettingException("Minimum value should be < Maximum value"); } public void checkValueInteger(int i) throws SettingException { if (activated && i >= maxValue.getDoubleValue()) throw new SettingException("Minimum value should be < Maximum value"); } public void checkValueLong(long i) throws SettingException { if (activated && i >= maxValue.getDoubleValue()) throw new SettingException("Minimum value should be < Maximum value"); } }); maxValue.addConstraint(new NumericConstraint() { public void checkValueDouble(double d) throws SettingException { if (activated && d <= minValue.getDoubleValue()) throw new SettingException("Maximum value should be > Minimum value"); } public void checkValueInteger(int i) throws SettingException { if (activated && i <= minValue.getDoubleValue()) throw new SettingException("Maximum value should be > Minimum value"); } public void checkValueLong(long i) throws SettingException { if (activated && i <= maxValue.getDoubleValue()) throw new SettingException("Minimum value should be > Maximum value"); } }); minimumPower.addConstraint(new NumericConstraint() { public void checkValueDouble(double d) throws SettingException { if (activated && d >= maximumPower.getDoubleValue()) throw new SettingException("Minimum power should be < Maximum power"); } public void checkValueInteger(int i) throws SettingException { if (activated && i >= maximumPower.getDoubleValue()) throw new SettingException("Minimum power should be < Maximum power"); } public void checkValueLong(long i) throws SettingException { if (activated && i >= maximumPower.getDoubleValue()) throw new SettingException("Minimum power should be < Maximum power"); } }); maximumPower.addConstraint(new NumericConstraint() { public void checkValueDouble(double d) throws SettingException { if (activated && d <= minimumPower.getDoubleValue()) throw new SettingException("Maximum power should be > Minimum power"); } public void checkValueInteger(int i) throws SettingException { if (activated && i <= minimumPower.getDoubleValue()) throw new SettingException("Maximum power should be > Minimum power"); } public void checkValueLong(long i) throws SettingException { if (activated && i <= minimumPower.getDoubleValue()) throw new SettingException("Maximum power should be > Minimum power"); } }); doEnables(); display = null; activated = true; updateAxis(); setChanged(); notifyObservers(); }