Home > front end >  How to customize date format of SimpleDateFormat() in Java (android)?
How to customize date format of SimpleDateFormat() in Java (android)?

Time:10-03

In my PHP webpage, I used this code (given below), which gives me the day's date in my desired format, which is (example) 2nd Oct. 2021.

<?php
date_default_timezone_set('Asia/Calcutta');
echo date('jS M\. Y'); //result = 2nd Oct. 2021
?>

Now, I want to achieve the same with Java - when I tried adding the format jS M\. Y in Java (android), it showed me some errors I'm unable to understand... Here's what I've tried in Java -

String date = new SimpleDateFormat("jS M\. Y", Locale.getDefault()).format(new Date());

I am currently new to Java & just found out about this class, so I don't know a lot of things

  • Related