Server Side Programming Articles

Page 139 of 2107

How to print date using GregorianCalendar class in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 1K+ Views

The GregorianCalendar class supports standard calendars it supports Julian and Gregorian calendars you can create an object of GregorianCalendar using one of its constructors. Following are various examples demonstrating how to print date using this class −ExampleFollowing example creates GregorianCalander by passing year, month and date values as parameters to its constructor and prints the date −import java.util.Calendar; import java.util.GregorianCalendar; public class Test {    public static void main(String args[]){       //Instantiating the GregorianCalendar       GregorianCalendar cal = new GregorianCalendar(2018, 6, 27);       System.out.println(cal);       System.out.println("Date: "+cal.get(Calendar.DATE));       System.out.println("Month: "+cal.get(Calendar.MONTH)); ...

Read More

How to find the sum of values based on key in other column of an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 688 Views

If we have a column that is key that means we want to use that column as an independent variable and find the statistical values such as sum, mean, standard deviation, range, etc. for the dependent variable. This can be done with the combination of with and tapply function as shown in the below examples.Consider the below data frame −Examplex1

Read More

How to format time using printf() method in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 272 Views

The printf() method is used to print a formatted string, it accepts a string representing a format string and an array of objects representing the elements that are to be in the resultant string, if the number of arguments are more than the number of characters in the format string the excess objects are ignored.Following table lists the various format characters to print date printf() method along with their description −Format CharactersDescription'B'The corresponding argument is formatted as full month name.'b'The corresponding argument is formatted as abbreviated month name.'h'The corresponding argument is formatted as abbreviated month name.'A'The corresponding argument is formatted as ...

Read More

How to find the length of the largest string in an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 976 Views

The length of the largest string can be found with the help of max function combined with nchar function. For this purpose, we first need to access the appropriate column that contains string values. Suppose, we have a data frame called df that contains a string column defined as CHAR then the length of the largest string will be found by using the command max(nchar(df$CHAR)).Consider the below data frame −Examplex

Read More

How to use formatting with printf() correctly in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 378 Views

The printf() method is used to print a formatted string, it accepts a string representing a format string and an array of objects representing the elements that are to be in the resultant string, if the number of arguments are more than the number of characters in the format string the excess objects are ignored.Following table lists the various format characters to format time by the Java printf() method along with their description −Format CharactersDescription'H'The corresponding argument is formatted as Hour of the day (00-24).'I'The corresponding argument is formatted as hour of the day (01 -12).'k'The corresponding argument is formatted ...

Read More

How to find the first quartile for a data frame column in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

The first quartile is the value that exists at the 25th percentile, that means there are 25% of values in the data that lie below first quartile. When we find the summary of data frame the output returns this value but if we want to extract only the first quartile then quantile function can be used by specifying the percentage using 0.25.Consider the below data frame −Examplex

Read More

How to measure elapsed time in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 5K+ Views

In general, the elapsed time is the time from the starting point to ending point of an event. Following are various ways to find elapsed time in Java −Using the currentTimeMillis() methodThe currentTimeMillis() method returns the current time in milliseconds. To find the elapsed time for a method you can get the difference between time values before and after the execution of the desired method.Examplepublic class Example {    public void test(){ int num = 0;       for(int i=0; i

Read More

What are date temporal fields in Java?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 3K+ Views

A temporal field is a field of date-time, such as month-of-year or hour-of-minute. These fields are represented by the TemporalField interface and the ChronoField class implements this interface.Following are the list of various temporal fields regarding date supported by the ChronoField class −FieldDescriptionALIGNED_DAY_OF_WEEK_IN_MONTHThis field represents the day of the week with in a month.ALIGNED_DAY_OF_WEEK_IN_YEARThis field represents the aligned day of a week in an year.ALIGNED_WEEK_OF_MONTHThis field represents the aligned wee of a month.ALIGNED_WEEK_OF_YEARThis field represents the aligned week of an year.DAY_OF_MONTHThis field represents the day of a month.DAY_OF_WEEKThis field represents the day of a week.DAY_OF_YEARThis field represents the day of ...

Read More

How to create boxplot using ggplot2 without whiskers in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 938 Views

To create boxplot using ggplot2 without whiskers, we need to use coef argument inside geom_boxplot function. For example, if we have data frame called df and there exists one categorical variable x and one response variable y then the boxplots for categories without whiskers can be created by using ggplot(df,aes(x,y))+geom_boxplot(coef=0).Consider the below data frame −Examplex

Read More

What is Java reg ex to check for date and time?

Maruthi Krishna
Maruthi Krishna
Updated on 11-Mar-2026 2K+ Views

To match a regular expression with the given string You need to:.Compile the regular expression of the compile() method of the Pattern class.Get the Matcher object bypassing the required input string as a parameter to the matcher() method of the Pattern class.The matches() method of the Matcher class returns true if a match occurs else it returns false. Therefore, invoke this method to validate the data.ExampleFollowing is a Java regular expression example matches only dateimport java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Sample {    public static void main(String args[]){       //Creating the list to store ...

Read More
Showing 1381–1390 of 21,061 articles
« Prev 1 137 138 139 140 141 2107 Next »
Advertisements