[Solved] Format date by provided time zone in java [duplicate]

[ad_1] Use the modern Java date and time classes for everything that has got to do with dates or times. DateTimeFormatter usFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withLocale(Locale.US); System.out.println(date.format(usFormatter)); DateTimeFormatter deFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withLocale(Locale.GERMANY); System.out.println(date.format(deFormatter)); This will print something like 6/27/17 27.06.17 It’s not exactly the formats you asked for, but it’s the formats Java thinks are appropriate … Read more

[Solved] How can I read this string in Java? [closed]

[ad_1] Here are several ways to get the first character: String str = “x , y – zzzzzz”; System.out.println(str.charAt(0)); System.out.println(str.substring(0, 1)); System.out.println(str.replaceAll(“^(.).*”, “$1”)); See IDEONE demo Choose the one you like more 🙂 UPDATE: To find the first word, you may use the following regex pattern: String pattern = “[\\s\\p{P}]+”; \s stands for whitespace, and … Read more

[Solved] how to redirect system input to javaFX textfield?

[ad_1] Preface: Given your “console application” doesn’t involve forking any processes or performing any “actual” I/O, you may want to redesign your application to use the TextField and TextArea directly, or at least more directly than you’re currently trying to do. Using System.out and System.in adds a layer of unnecessary indirection and makes everything more … Read more

[Solved] Java: How to access implementation of a method of Sub class from Super class

[ad_1] Consider following: public interface Animal { bool isVertebrate(); bool isDomesticable(); } and an abstract class that implements this interface: abstract class Cat implements Animal { public bool isVertebrate() {return true;} public void dealWithCat(){ if (isDomesticable()){ … } } But implementation for isDomesticable is delegated to subclass: public class Tiger extends Cat { public bool … Read more

[Solved] math need a number between -180 and 180

[ad_1] You could solve it like this: private static final int MIN = -180; private static final int MAX = 180; public static void main(String[] args) { System.out.println(keepInRange(-150 + 90)); System.out.println(keepInRange(0 + 90)); System.out.println(keepInRange(150 + 90)); System.out.println(keepInRange(-150 – 90)); } private static int keepInRange(final int value) { if (value < MIN) { /* * subtract … Read more

[Solved] OpenCV to android Opencv (JAVA)

[ad_1] I hope this might help you as I am doing something similar. Mat gray8 = new Mat(marked.size(), CvType.CV_8UC1); Imgproc.cvtColor(marked, gray8, Imgproc.COLOR_RGB2GRAY); Scalar mean = Core.mean(gray8); Imgproc.threshold(gray8, gray8, mean.val[0], 255, Imgproc.THRESH_BINARY); /*Imgproc.erode(gray8, gray8, new Mat(), new Point(-1, -1), 2);*/ List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); MatOfInt4 hierarchy = new MatOfInt4(); Imgproc.findContours(gray8, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); Toast.makeText(getApplicationContext(), … Read more

[Solved] I am working on OCR reader application. below is my java code. My question is how to start another method if one is completed?

[ad_1] just use the same mode on text to speech ADD and it will play when the first one is done, ADD = ADD, FLUSH = reset textToSpeech.speak(“this will play when first is done”, TextToSpeech.QUEUE_ADD, null); [ad_2] solved I am working on OCR reader application. below is my java code. My question is how to … Read more

[Solved] Calculate the distance between two points

[ad_1] import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity{ Cal cal; TextView textView; public void onCreate(Bundle s){ super.onCreate(s); setContentView(R.layout.<your layout name>); // You can not set id of any view here cal = new Cal(this); // This is a object cal.cal(); textView.setText(“”+ cal.result); // set the value instead of view object } … Read more

[Solved] How to replace a substring with ( from a string

[ad_1] This regex String a = “Want to Start (A) Programming and (B) Designing”; String b = a.replaceAll(“\\(“, “\n\\(“); System.out.println(b); results in Want to Start (A) Programming and (B) Designing Just escape the brackets with \\ and you’re fine. Edit: more specific, like mentioned below a.replaceAll(“(\\([AB]\\))”, “\n$1”); to match only (A) and (B) or a.replaceAll(“(\\(\\w\\))”, … Read more

[Solved] how to display values in jsp through java class [closed]

[ad_1] i think you should try this public class EmpBean { public java.util.List dataList(){ ArrayList list=new ArrayList(); try{ Class.forName(“driver”); Connection con = DriverManager.getConnection(“url”, “user”, “pwd”); Statement st=con.createStatement(); System.out.println(“hiiiii”); ResultSet rs=st.executeQuery(“select * from employee”); while(rs.next()){ list.add(rs.getString(“name”)); list.add(rs.getString(“address”)); list.add(rs.getString(“contactNo”)); list.add(rs.getString(“email”)); } System.out.println(rs.getString(“contactNo”)); } catch(Exception e){} return list; } } Assuming this class working fine and it is … Read more