
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

1K+ Views
The variables in an R data frame are referred to as the columns of the data frame. Sometimes we have a threshold value for a particular column and we need to check whether all the values in that column are greater than or less than the threshold. For this purpose, we can make use of ifelse function as shown in the below examples.Example1 Live DemoConsider the below data frame −set.seed(24) x

428 Views
To create a vector of weekdays we can use the command weekdays(Sys.Date()+0:6) and if we want to create a random sample of week days then sample function can be used along with the weekdays command. For example, if we want to create a random sample of 20 days then it can be done as sample(weekdays(Sys.Date()+0:6),20,replace=TRUE).Examples Live DemoExample1

7K+ Views
Using the of() methodThe of() method of the java.time.LocalDate class accepts the values of the year, month, and day of month as parameters, creates and returns an object of the LocalDate.ExampleLive Demoimport java.time.LocalDate; public class Test { public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 9, 11); System.out.println("Date Value: "+date); } }OutputDate Value: 2014-09-11Using the GregorianCalendar classOne of the constructors of the java.util.GregorianCalendar class accepts the values of year, month and day of month as values and creates a Calendar object representing it.Exampleimport java.util.*; class Test { public static void main(String args[]){ ... Read More

808 Views
If we have similar characteristics in each column of an R data frame then we can replace the missing values with row means. To replace the missing values with row means we can use the na.aggregate function of zoo package but we would need to use the transposed version of the data frame as na.aggregate works for column means.Example1Consider the below data frame − Live Demox1

40K+ Views
You can get the current date in Java in various ways. Following are some of them −The constructor of Date classThe no-arg constructor of the java.util.Date class returns the Date object representing the current date and time, using this you can print the current date as shown below −ExampleLive Demoimport java.text.SimpleDateFormat; import java.text.ParseException; import java.util.Date; public class Demo { public static void main(String args[])throws ParseException { Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy"); String str = formatter.format(date); System.out.print("Current date: "+str); } ... Read More

447 Views
The java.text.SimpleDateFormat class is used to format and parse a string to date and date to string.Parsing a date stringOne of the constructors of this class accepts a String value representing the desired date format and creates SimpleDateFormat object. To parse/convert a string as a Date objectInstantiate this class by passing desired format string.Parse the date string using the parse() method.ExampleLive Demoimport java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Sample { public static void main(String args[]) throws ParseException { String date_string = "2007-25-06"; //Instantiating the SimpleDateFormat class SimpleDateFormat formatter = ... Read More

6K+ Views
Using the ConstructorThe java.sql.Date represents the date value in JDBC. The constructor of this class accepts a long value representing the desired date and creates respective Date object.Date(long date)You can create this object using this constructor.ExampleLive Demoimport java.text.ParseException; import java.text.SimpleDateFormat; public class Demo { public static void main(String args[]) throws ParseException { String str = "26-09-1989"; SimpleDateFormat obj = new SimpleDateFormat("dd-MM-yyyy"); long epoch = obj.parse(str).getTime(); System.out.println("Date value: "+epoch); //Creating java.util.Date object java.util.Date date = ... Read More

676 Views
If the data frame contains a factor column and some numerical columns then we might want to find the sum of numerical columns for the factor levels. For this purpose, we can use aggregate function. For example, if we have a data frame df that contains a factor column defined by Group and some numerical columns then the sum by distinct column for factor levels can be calculated by using aggregate(.~Group,data=df,sum)Example1 Live DemoConsider the below data frame −Group

33K+ Views
Using the Date classYou can create a Date object using the Date() constructor of java.util.Date constructor as shown in the following example. The object created using this constructor represents the current time.ExampleLive Demoimport java.util.Date; public class CreateDate { public static void main(String args[]) { Date date = new Date(); System.out.print(date); } }OutputThu Nov 02 15:43:01 IST 2018Using the SimpleDateFormat classUsing the SimpleDateFormat class and the parse() method of this you can parse a date string in the required format and create a Date object representing the specified date.ExampleLive Demoimport java.text.ParseException; ... Read More

1K+ Views
JSE (Java Standard Edition)By using JavaSE you can develop stand-alone application ex: adobe reader, anti-virus, media players, etc. Java SE is also known as core java.lang: Language basics.util: Collection framework, events, data structure and other utility classes such as date.io: File operations, and other input and output operations.math: Multi precision arithmetics.nio: Non-blocking I/O framework for Java.net: Classes an API’s related to networking.security: This package provides classes and interfaces such as key generation, encryption, and decryption which belongs to the security framework.sql: Classes and interfaces for accessing/manipulating the data stored in databases and data sources.awt: Classes and interfaces to create GUI ... Read More