package lt.vilnius.tvarkau.utils;

import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.style.URLSpan;
import android.widget.TextView;

import org.threeten.bp.LocalDate;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;

public class FormatUtils {

    public static String formatLocalDateTime(LocalDateTime localDateTime) {

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        return localDateTime.format(formatter);
    }

    public static String formatLocalDateTimeToSeconds(LocalDateTime localDateTime) {

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return localDateTime.format(formatter);
    }

    public static String formatLocalDate(LocalDate localDate) {

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return localDate.format(formatter);
    }

    public static void removeUnderlines(TextView textView) {

        class URLSpanNoUnderline extends URLSpan {
            public URLSpanNoUnderline(String url) {
                super(url);
            }
            @Override public void updateDrawState(TextPaint ds) {
                super.updateDrawState(ds);
                ds.setUnderlineText(false);
            }
        }

        Spannable s = new SpannableString(textView.getText());
        URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
        for (URLSpan span: spans) {
            int start = s.getSpanStart(span);
            int end = s.getSpanEnd(span);
            s.removeSpan(span);
            span = new URLSpanNoUnderline(span.getURL());
            s.setSpan(span, start, end, 0);
        }
        textView.setText(s);
    }
}

@@ -28,16 +28,60 @@
 utils;%0A%0A
+import android.support.annotation.Nullable;%0A
 import a
@@ -99,24 +99,24 @@
 .Spannable;%0A
-
 import andro
@@ -831,32 +831,46 @@
 matter);%0A    %7D%0A%0A
+    @Nullable%0A
     public stati
@@ -894,16 +894,26 @@
 calDate(
+@Nullable 
 LocalDat
@@ -923,25 +923,42 @@
 ocalDate) %7B%0A
-%0A
+        try %7B%0A    
         Date
@@ -1026,32 +1026,36 @@
 M-dd%22);%0A        
+    
 return localDate
@@ -1066,32 +1066,100 @@
 mat(formatter);%0A
+        %7D catch (Exception ex) %7B%0A            return null;%0A        %7D%0A
     %7D%0A%0A    publi
@@ -1348,32 +1348,33 @@
 ;%0A            %7D%0A
+%0A
             @Ove
@@ -1378,16 +1378,28 @@
 Override
+%0A           
  public 
@@ -1674,24 +1674,24 @@
 pan.class);%0A
-
         for 
@@ -1703,16 +1703,17 @@
 pan span
+ 
 : spans)

Make formatLocalDate nullable