I resolved this the below way in appium-java client:
Android emulator API level: 28
Android emulator version: 9
Appium java client version: 5.0.4
currentMonthElement is the WebElement that represent the month field in the datepicker. you can use the find by xpath or whichever way you like to find this element. The below code can be reused to enter value for date and year elements. In the place of currentMonthElement variable, please pass the date and year elements.
touchAction.longPress(LongPressOptions.longPressOptions().withElement(ElementOption.element(currentMonthElement))).release().perform();
driver.getKeyboard().sendKeys(Keys.DELETE);
String monthstr = “Aug”;
//This while loop is required since sometimes the month “Aug” was not successfully entered at the first attempt.
while(!currentMonthElement.getText().equals(monthstr)){
driver.getKeyboard().sendKeys(“Aug”);
}
//click on the ok button after setting the date, month and year using the above code.
driver.findElement(By.id(“button1”)).click();