Format Currencies in JSP

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

The tag is used to format numbers, percentages, and currencies.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueNumeric value to displayYesNonetypeNUMBER, CURRENCY, or PERCENTNoNumberpatternSpecify a custom formatting pattern for the output.NoNonecurrencyCodeCurrency code (for type = "currency")NoFrom the default localecurrencySymbolCurrency symbol (for type = "currency")NoFrom the default localegroupingUsedWhether to group numbers (TRUE or FALSE)NotruemaxIntegerDigitsMaximum number of integer digits to printNoNoneminIntegerDigitsMinimum number of integer digits to printNoNonemaxFractionDigitsMaximum number of fractional digits to printNoNoneminFractionDigitsMinimum number of fractional digits to printNoNonevarName of the variable to store the formatted numberNoPrint to pagescopeScope of the variable to store the formatted numberNopageExample       ... Read More

LocalDateTime getMonthValue Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

124 Views

The month of the year is obtained using getMonthValue() method in the LocalDateTime class in Java. This method requires no parameter and it returns the month of the year which may be in the range of 1 to 12.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.parse("2019-02-18T23:15:30"); System.out.println("The LocalDateTime is: " + ldt); System.out.println("The month is: " + ldt.getMonthValue()); ... Read More

Create Ennead Tuple from Another Collection in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

141 Views

To create Ennead Tuple from another collection, use the fromCollection() method. Using this method, create an Ennead Tuple using List collection. Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package.import org.javatuples.Ennead;Note Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe ... Read More

Perform Aggregation and Sort in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

267 Views

You can use aggregate() method along with $sort() operator for this. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.aggregationSortDemo.insertOne({"StudentId":98, "StudentFirstName":"John", "StudentLastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90140c5705caea966c5587") } > db.aggregationSortDemo.insertOne({"StudentId":128, "StudentFirstName":"Carol", "StudentLastName":"Taylor"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90141b5705caea966c5588") } > db.aggregationSortDemo.insertOne({"StudentId":110, "StudentFirstName":"David", "StudentLastName":"Miller"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90142f5705caea966c5589") } > db.aggregationSortDemo.insertOne({"StudentId":139, "StudentFirstName":"Chris", "StudentLastName":"Brown"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90146a5705caea966c558a") } > db.aggregationSortDemo.insertOne({"StudentId":125, "StudentFirstName":"Sam", "StudentLastName":"Williams"}); {    "acknowledged" : true, ... Read More

Declare Global Variables in Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

5K+ Views

This example demonstrates How to declare global variables in Android?Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view to show global variable.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView actionEvent;    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)    @Override    protected void onCreate(Bundle ... Read More

Macros vs Functions in C

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section we will see what are the differences between macros and functions in C. The macros are pre-processed, so it means that all the macros will be preprocessed while it is compiled. The functions are not preprocessed, but compiled.In macros no type checking is done, so it may occur some problems for different types of inputs. In the case of functions, this is not done. Also for macros if the inputs are not properly maintained, then it may generate some invalid results. Please check the following program to get the idea about the problem.Example#include #define SQUARE(x) x ... Read More

Count Number of Ones in Register B - 8085 Program

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

3K+ Views

In this program, we will see how to count the number of 1’s in an 8-bit number stored in register B.Problem StatementWrite 8085 Assembly language program to count the number of 1s in 8-bit number stored in register B.DiscussionIn this program, we are using the rotate operation to count the number of 1’s. As there are 8 different bits in 8-bit number, then we are rotating the number eight times. we can use RRC or RLC. Here we have used the RRC instruction. This instruction sends the LSb to MSb also to carry flag. So after each iteration, we can ... Read More

Compare Binary and Sequential Search in C++

Chandu yadav
Updated on 30-Jul-2019 22:30:25

604 Views

Binary Search and Sequential or Linear Search both are used in computer programming to search an element. The time complexity of Binary Search is O(log(n)) and Sequential Search is O(n).AlgorithmBegin    Algorithm for Binary Search:    BinarySearch() function with ‘arr’ the array of data and ‘n’ the number of values, start and end index, iteration count and element to be searched in the argument list.    Increment iteration counter and compare the item value with the a[mid].    If item < a[mid] choose first half otherwise second half to proceed further.    Return iteration value on successful search. EndExample Code#include ... Read More

Delete Document from MongoDB Collection Using deleteOne Method

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

297 Views

To delete document from a collection in MongoDB, you can use the deleteOne() method. Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display all the documents from the collection. The query is as follows:> db.deleteDocumentsDemo.find().pretty();The following is the output:{    "_id" : ObjectId("5c6ab0e064f3d70fcc914805"),    "Name" : "Larry",    "Age" : 23 } {    "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"),    "Name" : "Mike",    "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" : "Sam", ... Read More

Declare Object of a Class Using JSP Declarations

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

1K+ Views

A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.Following is the syntax for JSP Declarations −You can write the XML equivalent of the above syntax as follows − code fragment Following is an example of Object declaration in JSP Declarations −

Advertisements