DatePicker not clicking single digit dates | Selenium Forum
P
Preetinder Virk Posted on 03/02/2020

Hi,

 

I am browsing Module 18 and for the AddDeleteStockTest.java file the datepicker is not picking up single digit dates(<10) My code is below:

 

package testcases;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;


public class AddDelStockTest {
WebDriver driver;

@Test(priority=1)
public void addStockTest() throws InterruptedException{

String browser = "Chrome";// xls, xml
// script
if(browser.equals("Mozilla")){
driver = new FirefoxDriver();
}else if(browser.equals("Chrome")){
driver = new ChromeDriver();
}else if(browser.equals("IE")){
driver = new InternetExplorerDriver();
}else if(browser.equals("Edge")){
driver = new EdgeDriver();
}

driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://in.rediff.com/");
driver.findElement(By.xpath("//a[@class='moneyicon relative']")).click();
driver.findElement(By.xpath("//*[@id='signin_info']/a[1]")).click();
driver.findElement(By.id("useremail")).sendKeys("<your_emailID>");
driver.findElement(By.id("emailsubmit")).click();
// wait
WebDriverWait wait = new WebDriverWait(driver, 10);
//wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("userpass"))));

Wait<WebDriver> wait11 = new FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(5)).ignoring(NoSuchElementException.class);


WebElement clickseleniumlink = wait11.until(new Function<WebDriver, WebElement>(){

public WebElement apply(WebDriver driver ) {
return driver.findElement(By.id("userpass"));
}});


clickseleniumlink.sendKeys("<your_password>");
clickseleniumlink.sendKeys(Keys.ENTER);


driver.findElement(By.xpath("//a[@class='black']")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);


Thread.sleep(5000);

waitForPageToLoad();
WebElement e = driver.findElement(By.id("portfolioid"));
Select s = new Select(e);
s.selectByVisibleText("Reema111");
//
waitForPageToLoad();
driver.findElement(By.id("addStock")).click();
driver.findElement(By.id("addstockname")).sendKeys("Tata Steel Ltd");
driver.findElement(By.xpath("//div[text()='Tata Steel Ltd.']")).click();

driver.findElement(By.id("stockPurchaseDate")).click();
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
selectDate("05/10/2019");
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.id("addstockqty")).sendKeys("1");
driver.findElement(By.id("addstockprice")).sendKeys("5");
driver.findElement(By.id("addStockButton")).click();
waitForPageToLoad();
int rNum=getRowWithCellData("Tata Steel Ltd.");
System.out.println("Row " + rNum);
if(rNum==-1)
Assert.fail("Could not find the Stock");


}


/*
* @Test(priority=2,dependsOnMethods={"addStockTest"}) public void
* deleteStockTest(){ int rNum=getRowWithCellData("Tata Steel Ltd.");
* driver.findElement(By.xpath("//table[@id='stock']/tbody/tr["+rNum+"]/td[1]"))
* .click();
* driver.findElements(By.xpath("//input[@name='Delete']")).get(rNum-1).click();
* driver.switchTo().alert().accept(); waitForPageToLoad();
* driver.switchTo().defaultContent();
* rNum=getRowWithCellData("Tata Steel Ltd."); System.out.println(rNum);
* Assert.assertEquals(rNum, -1); }
*/

public void wait(int time){
try {
Thread.sleep(time*1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void waitForPageToLoad(){
JavascriptExecutor js = (JavascriptExecutor)driver;
int i=0;

while(i!=10){
String state = (String)js.executeScript("return document.readyState;");
System.out.println(state);

if(state.equals("complete"))
break;
else
wait(2);

i++;
}
wait(2);// wait of 2 sec between page status and jquery
// check for jquery status
i=0;
while(i!=10){

Boolean result= (Boolean) js.executeScript("return window.jQuery != undefined && jQuery.active == 0;");
System.out.println(result);
if(result )
break;
else
wait(2);
i++;

}

}

public void selectDate(String d){
// day, month , year
Date current = new Date();
SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy");
DateFormat formatter;

try {
Date selected = sd.parse(d);


String day = new SimpleDateFormat("dd").format(selected);



String month = new SimpleDateFormat("MMMM").format(selected);
String year = new SimpleDateFormat("yyyy").format(selected);
System.out.println(day+" --- "+month+" --- "+ year);
String desiredMonthYear=month+" "+year;


while(true){
String displayedMonthYear=driver.findElement(By.cssSelector(".dpTitleText")).getText();
if(desiredMonthYear.equals(displayedMonthYear)){
// select the day

Wait<WebDriver> wait22 = new FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(5)).ignoring(NoSuchElementException.class);
WebElement clickDatePicker = wait22.until(new Function<WebDriver, WebElement>(){

public WebElement apply(WebDriver driver ) {
return driver.findElement(By.xpath("//td[text()='"+day+"']"));
}});

clickDatePicker.click();

break;
}else{

if(selected.compareTo(current) > 0)
driver.findElement(By.xpath("//*[@id='datepicker']/table/tbody/tr[1]/td[4]/button")).click();
else if(selected.compareTo(current) < 0)
driver.findElement(By.xpath("//*[@id='datepicker']/table/tbody/tr[1]/td[2]/button")).click();

}
}

} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

public int getRowWithCellData(String data){
List<WebElement> rows = driver.findElements(By.xpath("//table[@id='stock']/tbody/tr"));
for(int rNum=0;rNum<rows.size();rNum++){
WebElement row = rows.get(rNum);
List<WebElement> cells = row.findElements(By.tagName("td"));
for(int cNum=0;cNum<cells.size();cNum++){
WebElement cell = cells.get(cNum);
if(!cell.getText().trim().equals("") && data.contains(cell.getText()))
return ++rNum;
}
}

return -1;// not found
}


}

 

Please inform how to go about this.

 

Thanks!


A
Ashish Thakur Replied on 04/02/2020

Did you try debugging the code?

Please share the screenshot along with the complete exception stack trace.


P
Preetinder Virk Replied on 04/02/2020

Hi,

 

Here are the Trace and screenshot. I was able to debug and get the displayedMonthYear=desiredMonthYear in the function selectDate but I get exception

FAILED: addStockTest

org.openqa.selenium.NoSuchElementException: Unable to locate element: //td[text()='"+day+"']

Now none of the dates(even those>10) are not getting selected.

 

Trace:

complete
true
12 --- March --- 2019
FAILED: addStockTest
org.openqa.selenium.NoSuchElementException: Unable to locate element: //td[text()='"+day+"']
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:1473:a362:a81e:1eff%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '13.0.1'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 72.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20200117190643, moz:geckodriverVersion: 0.25.0, moz:headless: false, moz:processID: 725, moz:profile: /var/folders/jb/j707q50968j..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 19.0.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: e7e67b26-0559-df4d-a695-84bc18a84cf4
*** Element info: {Using=xpath, value=//td[text()='"+day+"']}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at testcases.AddDelStockTest$2.apply(AddDelStockTest.java:259)
at testcases.AddDelStockTest$2.apply(AddDelStockTest.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
at testcases.AddDelStockTest.selectDate(AddDelStockTest.java:254)
at testcases.AddDelStockTest.addStockTest(AddDelStockTest.java:96)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1507)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================

Screen attached

Thanks

Responsive image

P
Preetinder Virk Replied on 04/02/2020

OK now its started printing dates >10 but not <10. I had tried to escape the quotes earlier. It works for dates >10 using command

By.xpath("//td[text()='"+day+"']"). But for dates<10  it gives

FAILED: addStockTest

org.openqa.selenium.NoSuchElementException: Unable to locate element: //td[text()='06']

For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html for example for

selectDate("06/07/2019"); The Date Picker remains open

Screen and trace below:

 

Trace:

FAILED: addStockTest
org.openqa.selenium.NoSuchElementException: Unable to locate element: //td[text()='06']
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: MacBook-Pro.local', ip: 'fe80:0:0:0:1473:a362:a81e:1eff%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '13.0.1'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 72.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20200117190643, moz:geckodriverVersion: 0.25.0, moz:headless: false, moz:processID: 1055, moz:profile: /var/folders/jb/j707q50968j..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 19.0.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: c6c53352-9ba7-584c-b504-0ad7a9d12397
*** Element info: {Using=xpath, value=//td[text()='06']}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at testcases.AddDelStockTest.selectDate(AddDelStockTest.java:254)
at testcases.AddDelStockTest.addStockTest(AddDelStockTest.java:96)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1507)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

SKIPPED: deleteStockTest
java.lang.Throwable: Method AddDelStockTest.deleteStockTest()[pri:2, instance:testcases.AddDelStockTest@1a84f40f] depends on not successfully finished methods
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:99)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1507)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
Default test
Tests run: 2, Failures: 1, Skips: 1
===============================================


===============================================
Default suite
Total tests run: 2, Passes: 0, Failures: 1, Skips: 1
===============================================

 

 

Screen attached

 

Responsive image

A
Ashish Thakur Replied on 05/02/2020

As is can see that the XPath you are trying to generate may not be working. Please try crosschecking the XPath before using it.


P
Preetinder Virk Replied on 05/02/2020

Hi,

I tried all possible ways:

1. String dayEx=day.stripLeading(); //to get rid of zero in front of integers<10

2. Both xpaths and cssselectors of type 

"//td[contains(text(),'"+day+"')]" and #datepicker>table>tbody>tr[class=dpTR]>td:nth-child('"+day+"')

3.

Wait<WebDriver> wait33 = new

FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(30))

.pollingEvery(Duration.ofMillis(5)).ignoring(NoSuchElementException.class);

WebElement clickDatePicker = wait33.until(new Function<WebDriver,

WebElement>(){

public WebElement apply(WebDriver driver ) {

return driver.findElement(By.xpath("//td[text()='"+day+"']")); }});

4.

  WebElement element11 =

  driver.findElement(By.xpath("//td[contains(text(),'"+day+"')]"));

  JavascriptExecutor executor = (JavascriptExecutor)driver;

  executor.executeScript("arguments[0].click();", element11);

5.

WebElement myelement = driver.findElement(By.xpath("//td[contains(text()," +

  day + ")]")); JavascriptExecutor jse2 = (JavascriptExecutor) driver;

  jse2.executeScript("arguments[0].scrollIntoView()", myelement);

  myelement.click(); System.out.println(myelement.getText().toString());

6.

Wait<WebDriver> wait33 = new

FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(30))

.pollingEvery(Duration.ofMillis(5)).ignoring(NoSuchElementException.class);

WebElement clickDatePicker = wait33.until(new Function<WebDriver,

WebElement>(){

public WebElement apply(WebDriver driver ) {

return driver.findElement(By.xpath("//td[text()='"+day+"']")); }});

Actions actions = new Actions(driver);

actions.moveToElement(clickDatePicker).click().build().perform();

And same situation: dates >10 are accepted and clicked but dates<10 are not clicked.

Would appreciate if someone could help. Thanks


A
Ashish Thakur Replied on 06/02/2020

Please export your project in a compressed ZIP file and share it with us.


P
Preetinder Virk Replied on 06/02/2020

Hi,

 

Attaching zip file

 

Best.


P
Preetinder Virk Replied on 15/02/2020

This is resolved as now with a simple line of code :

 

String day = new SimpleDateFormat("dd").format(selected).replaceFirst("^0+(?!$)", "");

 

it works now. This post can be closed.

 

Thanks


A
Ashish Thakur Replied on 18/02/2020

You can refer to the below code as well.

String day = new SimpleDateFormat("d").format(selected);

This will return the date without 0 in single-digit dates


P
Preetinder Virk Replied on 04/03/2020

This post can be closed