Samual Sam has Published 2492 Articles

Format and Parse Date in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:33:29

261 Views

To format a date in Java, firstly import the following package.import java.text.DateFormat;Now, create DateFormat object.DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT); DateFormat longFormat = DateFormat.getDateInstance(DateFormat.LONG);Use the format() method to format the above dates.System.out.println(shortFormat.format(new Date())); System.out.println(longFormat.format(new Date()));To parse the dates, use the parse() method.Example Live Demoimport java.text.DateFormat; import java.text.ParseException; import java.util.Date; public class Demo { ... Read More

Default values of static variables in C

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:31:52

3K+ Views

When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static ... Read More

Return values of printf() and scanf() in C

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:25:18

11K+ Views

The printf() and scanf() functions are required for output and input respectively in C. Both of these functions are library functions and are defined in the stdio.h header file.Details about the return values of the printf() and scanf() functions are given as follows −The printf() functionThe printf() function is used ... Read More

Java Program to return a Date set to the first possible millisecond of the day after midnight

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:24:18

76 Views

Let us first set the calendar object.Calendar calendar = Calendar.getInstance();Use the getMinimum() method in Java to return the minimum value for the given calendar field. We will use it to set the minute, hours second and milliseconds.For hour and minute.calendar.set(Calendar.HOUR_OF_DAY, calendar.getMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMinimum(Calendar.MINUTE));For second and milliseconds.// second calendar.set(Calendar.SECOND, calendar.getMinimum(Calendar.SECOND)); // ... Read More

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

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:20:51

479 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; ... Read More

How to clear console in C?

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:18:37

19K+ Views

There are several methods to clear the console or output screen and one of them is clrscr() function. It clears the screen as function invokes. It is declared in “conio.h” header file. There are some other methods too like system(“cls”) and system(“clear”) and these are declared in “stdlib.h” header file.Here ... Read More

Format date with SimpleDateFormat('MM/dd/yy') in Java

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:18:17

15K+ Views

Let us see how we can format date with SimpleDateFormat('MM/dd/yy')// displaying date Format f = new SimpleDateFormat("MM/dd/yy"); String strDate = f.format(new Date()); System.out.println("Current Date = "+strDate);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 ... Read More

Bounce In Right Animation Effect with CSS

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:17:25

212 Views

To implement Bounce In Right Animation Effect with CSS, you can try to run the following code −ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;     ... Read More

(limits.h) in C/C++

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:16:40

946 Views

The header files “limits.h” exists in C language while in C++ language. Several macros are defined in these header files. The limits specify that variable cannot store values beyond the limits.Some macros in “limits.h” or header file are as followsCHAR_BITLONG_MINLONG_MAXCHAR_MINCHAR_MAXINT_MININT_MAXSHRT_MINSHRT_MAXULONG_MAXHere is an example of in C++ language, ... Read More

What all is inherited from parent class in C++?

Samual Sam

Samual Sam

Updated on 26-Jun-2020 08:14:35

3K+ Views

In the object-oriented programming, we can inherit the characteristics of parent class. Parent class is known as base class while child class is known as derived class. The derived class can inherit data members, member functions of base class.If the data members are public, they can be accessed by derived ... Read More

Advertisements