Skip to main content

Date Time API

Issues with the Existing Date/Time APIs


1. Thread Safefty:- develpoers have to deal with concurrency issues.new date and time api in java 8 are immutable and thread safe and thus taking concurrency headache away from developers.

2. API Design and Ease of Understanding: good utility methods in new API
3. Zoned Date and Time Functinality is added.



4. The format that I have used in my project is basically a user defined format


String userdefinedDate=localdate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));
System.out.println(userdefinedDate);


====================================================================

Study Link

Working With LocalDate


LocalDate localDate = LocalDate.now();
LocalDate.of(2015, 02, 20);

LocalDate tomorrow = LocalDate.now().plusDays(1);
DayOfWeek sunday = LocalDate.parse("2016-06-12").getDayOfWeek()



package com.sandy;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

public class TestClass2 {

public static void main(String[] args) {

LocalDate localdate=LocalDate.now();
System.out.println(localdate);


System.out.println(localdate.getDayOfWeek());
System.out.println(localdate.getMonth());
System.out.println(localdate.getYear());



System.out.println("==========================");
System.out.println(localdate.getDayOfMonth()+"."+ localdate.getMonthValue() +"."+ localdate.getYear()+" ");
System.out.println(localdate.getDayOfMonth());


/*
* String
* formatterDate=localdate.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.
* LONG)); System.out.println(formatterDate);
*/

String userdefinedDate=localdate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));
System.out.println(userdefinedDate);
}

}

Comments

Popular posts from this blog

Clean Code Sonar Lint Java

Coding Guidelines 1. Sections of code should not be commented out (java:S125) CODE_SMELLCode smellMAJORMajor Programmers should not comment out code as it bloats programs and reduces readability. Unused code should be deleted and can be retrieved from source control history if required. 2. Standard outputs should not be used directly to log anything (java:S106) CODE_SMELLCode smellMAJORMajor When logging a message there are several important requirements which must be fulfilled: • The user must be able to easily retrieve the logs • The format of all logged message must be uniform to allow the user to easily read the log • Logged data must actually be recorded • Sensitive data must only be logged securely If a program directly writes to the standard outputs, there is absolutely no way to comply with those requirements. That's why defining and using a dedicated logger is highly recommended. Noncompliant Code Example System.out.println("My Message");  // Noncompliant Complia...

Xpath toughest

1. //span[contains(text(),'Please enter the comments!')]//following-sibling::div//input//following-sibling::textarea Some of the other Xpaths are 1. search RBGA //clicking on the new request //a[@title='Request a new workflow for RB General Approval Form']         @FindBy(xpath="//body[contains(@class,'ext-safari')]/form[contains(@name,'workOnIssueForm')]/table[contains(@class,'jiraform maxWidth')]/tbody/tr/td[contains(@class,'rb_formArea')]/fieldset[contains(@class,'rb_WorkON_FieldSet')]/table/tbody/tr/td/div[contains(@class,'rb_WorkON_FieldContainer')]/div[contains(@class,'rb_WorkON_FieldValueArea rb_WorkON_FieldValueArea_create rb_WorkON_ValueArea_Wide')]/table[contains(@class,'workonstdtable')]/tbody/tr/td/input[1]")     public WebElement tickMark;         @FindBy(xpath="//body[contains(@class,'ext-safari')]/form[contains(@name,'workOnIssueForm')]/table[contains(@class,...