Java Date UTC Parse getUTCMidnightZero(Date d)

Here you can find the source of getUTCMidnightZero(Date d)

Description

get UTC Midnight Zero

License

Apache License

Declaration

public static Date getUTCMidnightZero(Date d) 

Method Source Code

//package com.java2s;
/*// w w  w . j a  v a  2 s .  c o m
Copyright [2013-2014] eBay Software Foundation
    
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    
*/

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

import java.util.TimeZone;

public class Main {
    public static Date getUTCMidnightZero(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("GMT-0"));
        cal.setTime(d);

        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        return cal.getTime();
    }
}

Related

  1. getUTCDate(Date date)
  2. getUtcDate(Date date)
  3. getUtcDate(final int year, final int month, final int day)
  4. getUTCDate(int year, int month, int date, int h, int m, int s, int milli)
  5. getUTCDate(int year, int month, int day)
  6. parseDateAsUTC(String dateString)
  7. parsePartialUTCToDate(String utcDate)
  8. parseToUTCDate(String timestamp, String pattern)
  9. parseUTCDateToString(Date date)