Set Date Patterns with SimpleDateFormat in Java

karthikeya Boyini
Updated on 27-Jun-2020 13:22:33

577 Views

The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved) for Date and Time in JavaReference − Oracle JavaLetterDate or Time ComponentPresentationExamplesGEra designatorTextADYYearYear1996; 96YWeek yearYear2009; 09MMonth in yearMonthJuly; Jul; 07WWeek in yearNumber27WWeek in monthNumber2DDay in yearNumber189DDay in monthNumber10FDay of week in monthNumber2EDay name in weekTextTuesday; TueUDay number of week (1 = Monday, ..., 7 = Sunday)Number1AAm/pm markerTextPMHHour in day (0-23)Number0KHour in day (1-24)Number24KHour in am/pm (0-11)Number0hHour in am/pm (1-12)Number12mMinute in hourNumber30sSecond in minuteNumber55SMillisecondNumber978zTime zoneGeneral time zonePacific Standard Time; PST; GMT-08:00ZTime zoneRFC 822 time zone-800XTime zoneThe above pattern letters are combined ... Read More

Set Date Formats for Different Countries in Java

Samual Sam
Updated on 27-Jun-2020 13:21:27

456 Views

Firstly, set the locale −Locale[] strLocales = { US, UK, GERMANY};Now, let us set the date formats i.e. different constants −int[] constants = { SHORT, MEDIUM, LONG }; String[] str = { "SHORT", "MEDIUM", "LONG" };Loop through and get the different date formats for different countries −for (Locale country : strLocales) {    System.out.println(""+ country.getDisplayCountry() + ".....");    for (int i = 0; i < constants.length; i++) {       dateFormat = DateFormat.getDateInstance(constants[i], country);       System.out.println(str[i] + " constant = " + dateFormat.format(dt));    } }The following is an exampleExample Live Demoimport static java.text.DateFormat.*; import static java.util.Locale.*; import ... Read More

Draw a Shadow Under a UIView in iPhone iOS

Nitya Raut
Updated on 27-Jun-2020 13:21:09

222 Views

To make our UI appealing, we have to play around with multiple attributes in iOS development. To draw shadows around a View or below a view we have to play around Layers and Views.Let’s see this in two ways.Method 1 − Simply coding where ever required.self.layer.masksToBounds = NO; self.layer.cornerRadius = 2; self.layer.shadowOffset = CGSizeMake(-5, 10); self.layer.shadowRadius = 3; self.layer.shadowOpacity = 0.3;Method 2 − Creating IBDesignable and IBInspectable and Using with Story board.@IBDesignable class DesignableView: UIView { } extension UIView {    @IBInspectable    var shadowRadius: CGFloat {       get {          return layer.shadowRadius     ... Read More

Remove Characters in a Range from a Java StringBuffer Object

Anvi Jain
Updated on 27-Jun-2020 13:20:44

2K+ Views

In order to remove characters in a specific range from a Java StringBuffer Object, we use the delete() method. The delete() method removes characters in a range from the sequence. The delete() method has two parameters , start and end. Characters are removed from start to end-1 index.Declaration − The java.lang.StringBuffer.delete() method is declared as follows −Let us see a program to delete characters in a specific range from a Java StringBuffer Object.Example Live Demopublic class Example {    public static void main(String[] args) {       StringBuffer sb = new StringBuffer("Hello World");       System.out.println("Original StringBuffer Object: " ... Read More

Display Date with Day Name in Short Format in Java

karthikeya Boyini
Updated on 27-Jun-2020 13:20:44

3K+ Views

Firstly, set the format with SimpleDateFormat classFormat dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");Above, the “EEE” is set to display the name of the day i.e. Monday, Tuesday, Wednesday, etc.Now, to display the date −String res = dateFormat.format(new Date());The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class Demo {    public static void main(String[] argv) throws Exception {       Format dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");       String res = dateFormat.format(new Date());       System.out.println("Date = " + res);    } }OutputDate = Thu, 22/11/2018

8051 Microcontroller

Chandu yadav
Updated on 27-Jun-2020 13:20:08

7K+ Views

The 8051 Microcontroller is designed by Intel in 1981. 8051 is 40 pin DIP IC. This is an 8-bit microcontroller.It is a very famous Microcontroller of Intel family. As we know Microprocessor like 8085, Z-80 or M6800 contains the ALU, control unit and some registers, but there were no internal storages. The Microcontroller contains the RAM and ROM, IO ports inside it. Some microcontroller also contains the ADC in it. As most of the required components are inside the chip, so the cost of application is also reduced.These kinds of microcontrollers are used in different appliances like televisions, washing machines, ... Read More

Format Time Using Custom Format in Java

Samual Sam
Updated on 27-Jun-2020 13:20:01

228 Views

Firstly, set the time with SimpleDateFormat classFormat dateFormat = new SimpleDateFormat("h:m:s");Now, for custom format, let us fetch the hour, minute and second individuallyHour// hour dateFormat = new SimpleDateFormat("h"); String strHour = dateFormat.format(new Date()); System.out.println("Hour: "+strHour);Minute// minute dateFormat = new SimpleDateFormat("m"); String strMinute = dateFormat.format(new Date()); System.out.println("Minute: "+strMinute);Second// second dateFormat = new SimpleDateFormat("s"); String strSecond = dateFormat.format(new Date()); System.out.println("Second: "+strSecond);The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class Demo {    public static void main(String[] argv) throws Exception {       Format dateFormat = new SimpleDateFormat("h:m:s");       String str = dateFormat.format(new Date());   ... Read More

Create Border, Border Radius, and Shadow for UIView in iPhone iOS

Nancy Den
Updated on 27-Jun-2020 13:19:37

555 Views

In this article we’ll learn how to create borders and shadows. We’ll do it in two ways, one by directly coding and one by making it designable and an extension of UIView, which can be edited directly in the storyboard.Let’s see how to play around with borders in ios −Method 1 − Creating borders with simple coding –Borders are a property of layer, above which a View is drawn, a border has the following properties, Border color, border width.self.view.layer.borderColor = colorLiteral(red: 0.4392156899, green: 0.01176470611, blue: 0.1921568662, alpha: 1) self.view.layer.borderWidth = 5.0To create corner radius of a view we can useself.view.layer.cornerRadius ... Read More

Registers of 8085 Microprocessor

Arjun Thakur
Updated on 27-Jun-2020 13:19:34

21K+ Views

It has eight addressable 8-bit registers: A, B, C, D, E, H, L, F, and two 16-bit registers PC and SP. These registers can be classified as −General Purpose RegistersTemporary Registers: a) Temporary data register b) W and Z registersSpecial Purpose Registers: a)Accumulator b) Flag registers c) Instruction registerSixteen-bit Registers: a) ProgramCounter (PC) b) Stack Pointer (SP)General Purpose RegistersRegisters B, C, D, E, H, and L are general purpose registers in 8085 Microprocessor. All these GPRS are 8-bits wide. They are less important than the accumulator. They are used to store data temporarily during the execution of the program. For ... Read More

Change Date Formatting Symbols in Java

karthikeya Boyini
Updated on 27-Jun-2020 13:19:19

163 Views

For date formatting symbols, use the DateFormatSymbols class.Firstly, set weekdays using a string arrayString[] weekDays2 = { "", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };Now, set short week days withDateFormatSymbols mySymbols = new DateFormatSymbols(); mySymbols.setShortWeekdays(weekDays2);Get the date −dateFormat = new SimpleDateFormat("EEEE, dd MMM yyyy", mySymbols); System.out.println(dateFormat.format(new Date()));The following is an example −Example Live Demoimport java.text.SimpleDateFormat; import java.text.DateFormat; import java.text.DateFormatSymbols; import java.util.Date; public class Demo {    public static void main(String[] args) {       String[] weekDays1 = { "", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };       String[] weekDays2 = { "", "monday", "tuesday", "wednesday", "thursday", ... Read More

Advertisements