Java Parse Date Pattern YYYY parse(String source)

Here you can find the source of parse(String source)

Description

parse

License

Apache License

Declaration

private static Date parse(String source) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");

    private static Date parse(String source) {
        if (source.equalsIgnoreCase("today")) {
            return new Date();
        }/* www .  j av a 2  s .  c o  m*/
        if (source.equalsIgnoreCase("yesterday")) {
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, -1);
            return cal.getTime();
        }
        try {
            return DATE_FORMAT.parse(source);
        } catch (ParseException e) {
            return null;
        }
    }
}

Related

  1. parse(String s)
  2. parse(String s)
  3. parse(String s, String formatPattern)
  4. parse(String source)
  5. parse(String source)
  6. parse(String source, Date defaultValue)
  7. parse(String str)
  8. parse(String str)
  9. parse(String str)