[Solved] convert string time to date type in java

With java.sql.Time you retrieve the right value from your time field in mysql. import java.io.IOException; import java.sql.Time; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class teste { /** * @param args * @throws IOException */ public static void main(final String[] args) throws IOException { SimpleDateFormat sdf = new SimpleDateFormat(“HH:mm:ss”); try { Date data = sdf.parse(“21:00:00”); … Read more

[Solved] how to extract ipaddress,date&time,http:// in a log file using java [closed]

File file = new File(“test.txt”); String word = “abc,catch,profile”; Scanner scanner = null; try { scanner = new Scanner(file); } catch (FileNotFoundException e) { System.out.println(“Error ” + e); } // now read the file line by line while (scanner.hasNextLine()) { String line = scanner.nextLine(); StringTokenizer st = new StringTokenizer(word, “,”); while (st.hasMoreTokens()) { if (line.contains(st.nextToken())) … Read more

[Solved] Print command output [closed]

If you consult the documentation for printf in C and System.out.println in Java, you will see that they format output in different ways. This is because they are totally different, and I’m not sure why you expected them to produce the same results. If you want printf-style formatting in Java, consider using String.format() to format … Read more

[Solved] How can my syntax error be fixed?

Corrected and working code import java.util.*; public class HDtest9 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (true) { // have created infinite loop System.out.print(“Enter text: “); String sentence = in.nextLine(); System.out.println(“You have entered: ” + sentence); // to Print string System.out.println(“The total number of characters is ” + sentence.length()); … Read more

[Solved] Getting the size of a single String in a array of string in java?

package stackoverflow.q_24933319; public class FindLength { public static void main(String[] args) { String[] arr = {“abc”,”bgfgh”,”gtddsffg”}; System.out.println(“Array size is: ” + arr.length); for(String s : arr) { System.out.println(“Value is ” + s + “, length is ” + s.length()); } } } //Output: //Array size is: 3 //Value is abc, length is 3 //Value is … Read more

[Solved] Android App Crashing – List View – CSV file

Ok your program fails at this point: while ((line = reader.readLine()) != null) { String[] RowData = line.split(“,”); DataStates cur = new DataStates(); cur.setTitle(RowData[2]); cur.setPrice(RowData[3]); // now there is a ArrayIndexOutOfBoundsException cur.setDescription(RowData[4]); this.add(cur); } Index begins at 0 so I think the right code would be while ((line = reader.readLine()) != null) { String[] RowData … Read more

[Solved] Java loops with math symbols [closed]

From what I could make out of your question, I took your code made it compile and modified it: public class test { public static void functionC(int n) { for(int i = 0; i < n; i++) { System.out.println(“Hello world”); } } public static void main(String[] args){ functionC(5); } } This would be functionC. For … Read more

[Solved] split String in an array

You can simply use the String#split method on any element of the array, whose delimiter can be any character. Here is an example where I chose : to be the delimiter. String[] information = { “Castiel Li:123-456-7890” }; String[] args = information.split(“:”); String name = args[0]; String phoneNumber = args[1]; solved split String in an … Read more

[Solved] every day xpath are changing [closed]

If your xpath will always be changing, to get your Selenium code to work atleast there should be some pattern in how it changes, for example it may be dependent on current date. Then you can code accordingly to generate your xpath dynamically every time you run your script. If there is no such pattern … Read more