@Test public void testGetSecondsForShortString() { System.out.println("getSecondsForShort"); assertEquals(105, JMeterPluginsUtils.getSecondsForShortString("105")); assertEquals(105, JMeterPluginsUtils.getSecondsForShortString("105s")); assertEquals(60 * 15, JMeterPluginsUtils.getSecondsForShortString("15m")); assertEquals(60 * 60 * 4, JMeterPluginsUtils.getSecondsForShortString("4h")); assertEquals(104025, JMeterPluginsUtils.getSecondsForShortString("27h103m645s")); }
public static int getSecondsForShortString(String string) { int res = 0; string = string.trim(); String c; String curNum = ""; for (int n = 0; n < string.length(); n++) { c = String.valueOf(string.charAt(n)); if (c.matches("\\d")) { curNum += c; } else { int mul; switch (c.charAt(0)) { case 's': case 'S': mul = 1; break; case 'm': case 'M': mul = 60; break; case 'h': case 'H': mul = 60 * 60; break; case 'd': case 'D': mul = 60 * 60 * 24; break; default: throw new NumberFormatException("Shorthand string does not allow using '" + c + "'"); } res += Integer.parseInt(curNum) * mul; curNum = ""; } } if (!curNum.isEmpty()) { res += Integer.parseInt(curNum); } return res; }
JMeterPluginsUtils { public static int getSecondsForShortString(String string) { int res = 0; string = string.trim(); String c; String curNum = ""; for (int n = 0; n < string.length(); n++) { c = String.valueOf(string.charAt(n)); if (c.matches("\\d")) { curNum += c; } else { int mul; switch (c.charAt(0)) { case 's': case 'S': mul = 1; break; case 'm': case 'M': mul = 60; break; case 'h': case 'H': mul = 60 * 60; break; case 'd': case 'D': mul = 60 * 60 * 24; break; default: throw new NumberFormatException("Shorthand string does not allow using '" + c + "'"); } res += Integer.parseInt(curNum) * mul; curNum = ""; } } if (!curNum.isEmpty()) { res += Integer.parseInt(curNum); } return res; } }
JMeterPluginsUtils { public static int getSecondsForShortString(String string) { int res = 0; string = string.trim(); String c; String curNum = ""; for (int n = 0; n < string.length(); n++) { c = String.valueOf(string.charAt(n)); if (c.matches("\\d")) { curNum += c; } else { int mul; switch (c.charAt(0)) { case 's': case 'S': mul = 1; break; case 'm': case 'M': mul = 60; break; case 'h': case 'H': mul = 60 * 60; break; case 'd': case 'D': mul = 60 * 60 * 24; break; default: throw new NumberFormatException("Shorthand string does not allow using '" + c + "'"); } res += Integer.parseInt(curNum) * mul; curNum = ""; } } if (!curNum.isEmpty()) { res += Integer.parseInt(curNum); } return res; }  }
JMeterPluginsUtils { public static int getSecondsForShortString(String string) { int res = 0; string = string.trim(); String c; String curNum = ""; for (int n = 0; n < string.length(); n++) { c = String.valueOf(string.charAt(n)); if (c.matches("\\d")) { curNum += c; } else { int mul; switch (c.charAt(0)) { case 's': case 'S': mul = 1; break; case 'm': case 'M': mul = 60; break; case 'h': case 'H': mul = 60 * 60; break; case 'd': case 'D': mul = 60 * 60 * 24; break; default: throw new NumberFormatException("Shorthand string does not allow using '" + c + "'"); } res += Integer.parseInt(curNum) * mul; curNum = ""; } } if (!curNum.isEmpty()) { res += Integer.parseInt(curNum); } return res; }  static String prefixLabel(String label); static String getStackTrace(Exception ex); static CollectionProperty tableModelRowsToCollectionProperty(PowerTableModel model, String propname); static CollectionProperty tableModelRowsToCollectionPropertyEval(PowerTableModel model, String propname); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses); static String replaceRNT(String str); static String getWikiLinkText(String wikiPage); static String buildHelpPageUrl(String helpPage); static Component addHelpLinkToPanel(Container panel, String helpPage); static void doBestCSVSetup(SampleSaveConfiguration conf); static void openInBrowser(String string); static float getFloatFromString(String stringValue, float defaultValue); static int getSecondsForShortString(String string); static String getVersion(); static String getEnvDefault(String propName, String defaultVal); static void prepareJMeterEnv(String homeDir); static String getJMeterHomeFromCP(String classpathSTR); static String getShortHostname(String host); }
JMeterPluginsUtils { public static int getSecondsForShortString(String string) { int res = 0; string = string.trim(); String c; String curNum = ""; for (int n = 0; n < string.length(); n++) { c = String.valueOf(string.charAt(n)); if (c.matches("\\d")) { curNum += c; } else { int mul; switch (c.charAt(0)) { case 's': case 'S': mul = 1; break; case 'm': case 'M': mul = 60; break; case 'h': case 'H': mul = 60 * 60; break; case 'd': case 'D': mul = 60 * 60 * 24; break; default: throw new NumberFormatException("Shorthand string does not allow using '" + c + "'"); } res += Integer.parseInt(curNum) * mul; curNum = ""; } } if (!curNum.isEmpty()) { res += Integer.parseInt(curNum); } return res; }  static String prefixLabel(String label); static String getStackTrace(Exception ex); static CollectionProperty tableModelRowsToCollectionProperty(PowerTableModel model, String propname); static CollectionProperty tableModelRowsToCollectionPropertyEval(PowerTableModel model, String propname); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model); static void collectionPropertyToTableModelRows(CollectionProperty prop, PowerTableModel model, Class[] columnClasses); static String replaceRNT(String str); static String getWikiLinkText(String wikiPage); static String buildHelpPageUrl(String helpPage); static Component addHelpLinkToPanel(Container panel, String helpPage); static void doBestCSVSetup(SampleSaveConfiguration conf); static void openInBrowser(String string); static float getFloatFromString(String stringValue, float defaultValue); static int getSecondsForShortString(String string); static String getVersion(); static String getEnvDefault(String propName, String defaultVal); static void prepareJMeterEnv(String homeDir); static String getJMeterHomeFromCP(String classpathSTR); static String getShortHostname(String host); static final String WIKI_BASE; static final String ENCODING; static final Charset CHARSET; }