Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by karthikeya Boyini
Page 17 of 143
Long Time ("T") Format Specifier in C#
The Long Time format specifier represents a custom date and time format string.It is defined by DateTimeFormatInfo.LongTimePattern property.The custom format string.HH:mm:ssExampleusing System; using System.Globalization; class Demo { static void Main() { DateTime date = new DateTime(2018, 9, 9, 8, 15, 30); Console.WriteLine(date.ToString("T", CultureInfo.CreateSpecificCulture("en-us"))); } }Output8:15:30 AM
Read MoreWhat is the IsFixedSize property of Hashtable class in C#?
Use the isFixedSize property of Hashtable class to get a value indicating whether the Hashtable has a fixed size.The following is an example showing how to work with IsFixedSize property.Exampleusing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { Hashtable ht = new Hashtable(); ht.Add("D01", "Finance"); ht.Add("D02", "HR"); ht.Add("D03", "Operations"); Console.WriteLine("IsFixedSize = " + ht.IsFixedSize); Console.ReadKey(); } } }OutputIsFixedSize = FalseAbove we have ...
Read MoreDisplay hour with SimpleDateFormat(“H”) in Java
To work with SimpleDateFormat class in Java, import the following package.import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“H”) to display hour in a day.Format f = new SimpleDateFormat("H");Now, get the hour −String strHour = 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 Moreoctdec() function in PHP
The octdec() function converts octal to decimal.Syntaxoctdec(val)Parametersval − the octal string to convertReturnThe octdec() function Returns the decimal equivalent of the specified octal number.ExampleOutputa80ExampleLet us see another example −Output120170
Read MoreLeft pad an integer in Java with zeros
Let us see an example first to understand how an integer looks with left padding −888 //left padding with spaces 0000000999 //left padding with 7 zerosLet us see an example to left pad a number with zero −Examplepublic class Demo { public static void main(String[] args) { int val = 9899; System.out.println(String.format("%05d",val)); } }Output09899Let us see another example that pads a greater number of zeros −Examplepublic class Demo { public static void main(String[] args) { int val = 9899; System.out.println(String.format("%010d", val)); } }Output0000009899
Read MoreDisplay minutes with SimpleDateFormat('mm') in Java
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 Morepow() function in PHP
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 MoreFormat Calendar with String.format() in Java
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 MoreMake the first letter caps and the rest lowercase in Java
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 MoreJava Program to get full day name
To display the full day name, use the SimpleDateFormat(“EEEE”) as shown below −// displaying full-day name f = new SimpleDateFormat("EEEE"); String str = f.format(new Date()); System.out.println("Full Day Name = "+str);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 ...
Read More