Articles on Trending Technologies

Technical articles with clear explanations and examples

Display minutes with SimpleDateFormat('mm') in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 1K+ Views

To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“mm”) to display minutes in two-digits.Format f = new SimpleDateFormat(‘”mm”);Now, get the minutes in a string.String strMinute = f.format(new Date());The following is an example −Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s"); ...

Read More

Comparing enum members in C#

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 2K+ Views

To compare enum members, use the Enum.CompareTo() method.Firstly, set the values for students.enum StudentRank { Tom = 3, Henry = 2, Amit = 1 };Now use the compareTo() method to compare one enum value with another.Console.WriteLine( "{0}{1}", student1.CompareTo(student2) > 0 ? "Yes" : "No", Environment.NewLine );The following is the code to compare enum members in C#.Exampleusing System; public class Demo {    enum StudentRank { Tom = 3, Henry = 2, Amit = 1 };    public static void Main() {       StudentRank student1 = StudentRank.Tom;       StudentRank student2 = StudentRank.Henry;       StudentRank student3 ...

Read More

pow() function in PHP

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 245 Views

The pow() function Returns a raised to the power of b.Syntaxpow(a,b)Parametersa − The baseb − The exponentReturnThe pow() function Returns a raised to the power of b.ExampleOutput243ExampleLet us see another example −Output4096-5.0805263425291E-5ExampleLet us see another example −OutputNAN

Read More

FILTER_VALIDATE_URL constant in PHP

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 544 Views

The FILTER_VALIDATE_URL constant validates a URL.FlagsFILTER_FLAG_SCHEME_REQUIRED − URL must be RFC compliant.FILTER_FLAG_HOST_REQUIRED − URL must include host name.FILTER_FLAG_PATH_REQUIRED −URL must have a path after the domain name.FILTER_FLAG_QUERY_REQUIRED −URL must have a query string.ReturnThe FILTER_VALIDATE_URL constant does not return anything.ExampleOutputThe following is the output.Valid URL!Let us see another example.ExampleOutputHere is the output.Invalid URL!

Read More

Format Calendar with String.format() in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 997 Views

Firstly, consider an object with date value.Object arrObj[] = { "Date", Calendar.getInstance() };After that, use the String.format() method to format Calendar and display the date.The following is an example.Exampleimport java.util.Calendar; public class Demo {    public static void main(String []args){       Object arrObj[] = { "Date", Calendar.getInstance() };       System.out.println("Formatting Date...");       System.out.println(String.format("%1$s = %2$tY %2$tm %2$te", arrObj));    } }OutputFormatting Date... Date = 2018 11 17

Read More

Display complete date and time information using Formatter in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 169 Views

Firstly, create a Formatter and Calendar object.Formatter f = new Formatter(); Calendar cal = Calendar.getInstance();Now display the current date and time. We have shown the date here in both lowercase and uppercase −f = new Formatter(); System.out.println(f.format("Date and Time (lowercase): %tc", cal)); f = new Formatter(); System.out.println(f.format("Date and Time (uppercase): %Tc", cal));The following is an example −Exampleimport java.util.Calendar; import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar cal = Calendar.getInstance(); ...

Read More

C# Program to skip elements from a sequence as long as the specified condition is true

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 278 Views

Use the SkipWhile() method to skip elements from a sequence as long as the specified condition is true.The following is the array −int[] marks = { 35, 42, 48, 88, 55, 90, 95, 85 };Here is the condition.s => s >= 50As long as the above condition is true, the elements above 50 are skipped as shown below −Exampleusing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       int[] marks = { 35, 42, 48, 88, 55, 90, 95, 85 };       // skips elements above 50       IEnumerable selMarks = marks.AsQueryable().OrderByDescending(s => s).SkipWhile(s => s >=          50);       // displays rest of the elements       Console.WriteLine("Skipped marks > 60...");       foreach (int res in selMarks) {          Console.WriteLine(res);       }    } }OutputSkipped marks > 60... 48 42 35

Read More

rad2deg() function in PHP

Samual Sam
Samual Sam
Updated on 11-Mar-2026 100 Views

The rad2deg() function converts radian value to degree value. It Returns the equivalent of radia value val in degrees.Syntaxrad2deg(val)Parametersval − The radian value to be converted into degree.ReturnThe rad2deg() function Returns the equivalent of val in degrees.ExampleOutput180ExampleLet us see another example −Output90ExampleLet us see another example −Output22.5

Read More

Display the day in week using SimpleDateFormat('E') in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 717 Views

To display the day in week, use the SimpleDateFormat(“E”) as shown below −Format f = new SimpleDateFormat("E"); String strDayinWeek = f.format(new Date()); System.out.println("Day in week = "+strDayinWeek);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date.import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo {    public static void main(String[] args) throws Exception {       // displaying current date and time       Calendar cal = Calendar.getInstance();       SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s");   ...

Read More

Make the first letter caps and the rest lowercase in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 1K+ Views

The following is an example −Examplepublic class Demo {    public static void main(String[] args) {       String str = "laptop";       System.out.println("Original String = " +str);       // letter one       String strOne = str.substring(0,1).toUpperCase();       // remaining letters       String strTwo = str.substring(1).toLowerCase();       System.out.println("Resultant String = "+strOne + strTwo);    } }OutputOriginal String = laptop Resultant String = Laptop

Read More
Showing 9101–9110 of 61,248 articles
« Prev 1 909 910 911 912 913 6125 Next »
Advertisements