Java– category –
-
Java
Java Numeric⇔String⇔Date Conversion
[Converting numbers from strings] Use String.valueof() to convert numbers to strings. String str = String.valueOf(num); There are also other ways to write it. String str = Integer.toString(num); String str = "" + num; The last "" + num is the statement... -
Java
Summary of basic array operations in Java
[Initialize the array at the same time as the declaration] By writing the following, you can initialize the array at the same time as the declaration. Sample code static void arraySample() { String[] s = {"Apple", "Orange", "Banana"}; } System.out.println(s[1]); Output result: Orange [] In the array. .. -
Java
Checking Java variable types with instanceof
[Checking the type of a variable] Introducing a sample program to check the type of a variable in Java. Java is a statically typed language that declares types explicitly, so there is no opportunity to check the types that much. However, when using inherited objects, type checking may be necessary... -
Java
Summary of Basic String Manipulation in Java
[] Splits a string at a specific string (delimiter). Sample code public static void splitSample() { String line = "apples, oranges, bananas"; String[] fruits = line.split(","); for (String fruit : fruits) { System.out.println(fruit) ; } } Out... -
Java
Convert Java date string to Date type
[Acquire by type] This is a sample program that converts a date string (format yyyy/MM/dd) to java.util.Date type in Java. [Sample code] /** * Converts the date string "yyyy/MM/dd" to java.util.Date type. * @param str String to be converted * @return Change... -
Java
Convert any Java date/time string to Date or Calendar type
[] This is a sample program that converts any date or time string in Java to java.util.Calendar or java.util.Date type if possible. To convert, first format it to the default date/time string, and then convert it to the java.util.Calendar type. Conversion... -
Java
Java Tasktray Icons Displayed and Blinking
[] Introducing a utility class that displays and blinks the task tray (system tray) icon in Java. The utility class uses the java.awt.SystemTray and java.awt.TrayIcon classes, which are new features added in Java SE 6 Mustang. use... -
Java
Java Finds the current (today's) day of the week
[] This is a sample program that uses the Calendar class in Java to obtain the current (today) day of the week. Use Calendar.DAY_OF_WEEK to retrieve it. Calendar cal = Calendar.getInstance(); int week = cal.get(Calendar.DAY_OF_WEEK); Calendar.DAY_OF_WE... -
Java
Get Java memory usage
[] Returns the "total", "usage", and "maximum usable" information about the memory information of the Java virtual machine. The explanation of each item is as follows. Total...Runtime.getRuntime().totalMemory() is the amount of memory allocated to the Java virtual machine. amount to use···... -
Java
Output Java system properties in an easy-to-read format
[] Introducing a sample program that outputs system property keys and values in alphabetical order in Java for easy viewing. Once stored in TreeMap, it is sorted alphabetically and then output. Usually, the following methods are well introduced, but the value is... -
Java
Execute Java external command and get 3 results
[Obtain the result of )] Introducing a sample program that launches commands and external executable files such as batch shells in Java. Also, at the same time as the external command is executed, the standard output, error output, and return code are obtained as the return value of the method. Usually, outside of Java... -
Java
Get hostname from Java IP address
[] This is a sample program that obtains the host name (machine name) with the specified IP address. [] /** * Gets the host name with the specified IP address. * @param address IP address * @return host name * *If an unexpected exception occurs, the string "Unk... -
Java
Get the hostname of the machine running Java
[] Introducing a sample program that obtains the host name (machine name) of a machine running in Java. The sample program obtains the host name using the following method. Importing an InetAddress representing the local host using java.net.InetAddress.getLocalHost()... -
Java
Copy to Java Clipboard
[] Introducing sample source for copying a string to the clipboard using JavaSwing. Use java.awt.datatransfer.Clipboard to operate the clipboard in JavaSwing. Clipboard is retrieved like this. Clipboard clipboard = Toolkit.getDefaul... -
Java
Java Get end-of-month date
[] This is a sample program that obtains the end of the month date of a specified date in Java. The end date of the month can be obtained using getActualMaximum(Calendar.DATE) of the java.util.Calendar class. [] /** * The last day of the month in the specified date string (yyyy/MM/dd or yyyy-MM-dd) *... -
Java
Java Date validity/existence check
[] This is a sample program that checks the validity and existence of dates in Java. Checks whether the specified date string (yyyy/MM/dd or yyyy-MM-dd) exists on the calendar. If you specify false for setLenient() of the java.text.DateFormat class, date parsing... -
Java
Java Date/Time Calculation Addition and Subtraction Made Easy
[] Introducing a sample program that easily calculates addition and subtraction of dates and times using Java. The characteristics of the sample program are as follows. Returns the result of adding or subtracting the specified amount of time from the current or arbitrary date/time. If you specify a positive number, the time... -
Java
Java Find the difference between the number of months between two dates
[] Introducing a sample program in Java that calculates the difference in the number of months between two dates. In the sample program, the date to be compared is a string (yyyy/MM/dd) or java.util.Date. The calculation method for calculating the difference in months is as follows. First two... -
Java
Java Find the difference between two dates
[] Introducing a sample program to find the difference between two dates in Java. In the sample program, the date to be compared is a string (yyyy/MM/dd) or java.util.Date. The calculation method to find the difference in dates is as follows. First two days... -
Java
Save objects with Java XMLEncoder
[] Introducing a sample program that saves objects in XML format using Java. Use java.beans.XMLEncoder for XML output. We will also introduce a sample program that uses java.beans.XMLDecoder to restore a saved object. [] Plastic...
12