> For the complete documentation index, see [llms.txt](https://jobinjj.gitbook.io/tutorials/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jobinjj.gitbook.io/tutorials/menus-and-pickers/dateformat.md).

# DateFormat

### Add gradle to build.gradle

{% code title="build.gradle" %}

```markup
implementation 'si.virag:fuzzydateformatter:1.1.0'
```

{% endcode %}

### Converting date to string

```
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

    Date date = new Date();
    String dateTime = dateFormat.format(date);
```

### Converting string to date

{% code title="MainActivity.java" %}

```java
String dtStart = "2019-03-15T09:27:37Z";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
try {
    date = format.parse(dtStart);
    System.out.println(date);
    String text = FuzzyDateTimeFormatter.getTimeAgo(MainActivity.this, date);
} catch (ParseException e) {
    e.printStackTrace();
}
```

{% endcode %}
