Java Day dayForAMorPM(String date)

Here you can find the source of dayForAMorPM(String date)

Description

day For A Mor PM

License

Apache License

Declaration

public static int dayForAMorPM(String date) 

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 {

    public static int dayForAMorPM(String date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date dateparam = null;/*w  w w.  j av  a2  s  . c  o m*/
        try {
            dateparam = format.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dateparam);

        return calendar.get(Calendar.AM_PM);
    }

    public static int dayForAMorPM(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar.get(Calendar.AM_PM);
    }
}

Related

  1. dayDiff(Date date1, String date2)
  2. dayEnd(Date date)
  3. dayFillter(String text, String type)
  4. dayFillter(String text, String type)
  5. dayFilter(Date date)
  6. dayFormat(Date date)
  7. dayOfDate(Date s)
  8. dayOfWeekAbr(Date date)
  9. daysFrom(Date date, int amount, String format)