java.text.DateFormat.setCalendar()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中java.text.DateFormat.setCalendar()方法的一些代码示例,展示了DateFormat.setCalendar()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateFormat.setCalendar()方法的具体详情如下:
包路径:java.text.DateFormat
类名称:DateFormat
方法名:setCalendar

DateFormat.setCalendar介绍

[英]Sets the calendar used by this date format.
[中]设置此日期格式使用的日历。

代码示例

代码示例来源:origin: stackoverflow.com

public static String format(GregorianCalendar calendar){
  SimpleDateFormat fmt = new SimpleDateFormat("dd-MMM-yyyy");
  fmt.setCalendar(calendar);
  String dateFormatted = fmt.format(calendar.getTime());
  return dateFormatted;
}

代码示例来源:origin: apache/maven

public static DateFormat getUtcDateFormatter()
{
  DateFormat utcDateFormatter = new SimpleDateFormat( DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT );
  utcDateFormatter.setCalendar( new GregorianCalendar() );
  utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE );
  return utcDateFormatter;
}

代码示例来源:origin: apache/flink

dateFormat.setCalendar(ret);
dateFormat.setLenient(false);

代码示例来源:origin: stackoverflow.com

Long gmtTime =1317951113613L; // 2.32pm NZDT
Long timezoneAlteredTime = 0L;

if (offset != 0L) {
  int multiplier = (offset*60)*(60*1000);
  timezoneAlteredTime = gmtTime + multiplier;
} else {
  timezoneAlteredTime = gmtTime;
}

Calendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(timezoneAlteredTime);

DateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");

formatter.setCalendar(calendar);
formatter.setTimeZone(TimeZone.getTimeZone(timeZone));

String newZealandTime = formatter.format(calendar.getTime());

代码示例来源:origin: stackoverflow.com

SimpleDateFormat result = new SimpleDateFormat(pattern);
result.setCalendar(Calendar.getInstance(timeZone));
return result;

代码示例来源:origin: stackoverflow.com

localSimpleDateFormat.get().setCalendar(newCalendar);

代码示例来源:origin: stackoverflow.com

simpleDateFormat.setCalendar(calendar);
  date = simpleDateFormat.format(calendar.getTime());
simpleDateFormat.setCalendar(calendar);
String monthName = simpleDateFormat.format(calendar.getTime());
simpleDateFormat.setCalendar(calendar);
String monthName = simpleDateFormat.format(calendar.getTime());
simpleDateFormat.setCalendar(calendar);
String weekName = simpleDateFormat.format(calendar.getTime());
simpleDateFormat.setCalendar(calendar);
String weekName = simpleDateFormat.format(calendar.getTime());

代码示例来源:origin: apache/maven

utcDateFormatter.setCalendar( new GregorianCalendar() );
utcDateFormatter.setTimeZone( DEFAULT_SNAPSHOT_TIME_ZONE );

代码示例来源:origin: camunda/camunda-bpm-platform

public
DateTimeDateFormat(TimeZone timeZone) {
 this();
 setCalendar(Calendar.getInstance(timeZone));
}

代码示例来源:origin: camunda/camunda-bpm-platform

public
AbsoluteTimeDateFormat() {
 setCalendar(Calendar.getInstance());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public
AbsoluteTimeDateFormat(TimeZone timeZone) {
 setCalendar(Calendar.getInstance(timeZone));
}

代码示例来源:origin: stackoverflow.com

TimeZone tz = TimeZone.getTimeZone("Asia/Calcutta");
Calendar cal = Calendar.getInstance(tz);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
sdf.setCalendar(cal);
cal.setTime(sdf.parse("2013-07-17T03:58:00.000Z"));
Date date = cal.getTime();

代码示例来源:origin: com.cloudera.api/cloudera-manager-api

public static DateFormat makeISODateFormat() {
 DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
 Calendar cal = Calendar.getInstance(new SimpleTimeZone(0, "GMT"));
 iso8601.setCalendar(cal);
 return iso8601;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-fu

/**
 * @return a nicely formated date.
 */
public static final String date(long _time, int _format) {
 Date now = new Date(_time);
 Calendar cal = Calendar.getInstance();// calendarCET();
 DateFormat fmt;
 cal.setTime(now);
 fmt = DateFormat.getDateInstance(_format, Locale.getDefault());
 fmt.setCalendar(cal);
 return fmt.format(now);
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-fu

/**
 * @return a nicely formated date.
 */
public static final String date(long _time, String _simple) {
 Date now = new Date(_time);
 Calendar cal = Calendar.getInstance();// calendarCET();
 DateFormat fmt;
 cal.setTime(now);
 fmt = new SimpleDateFormat(_simple, Locale.getDefault());
 fmt.setCalendar(cal);
 return fmt.format(now);
}

代码示例来源:origin: stackoverflow.com

public static String getFormattedTimeLabel(final Time time, String tzId) {
 Calendar cal = new GregorianCalendar();
 cal.setTimeInMillis(time.getTime());
 SimpleDateFormat sdf = new SimpleDateFormat("HH : mm");
 sdf.setCalendar(cal);
 sdf.setTimeZone(tzId == null ? TimeZone.getDefault() : TimeZone.getTimeZone(tzId));
 return sdf.format(cal.getTime());
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public void setCalendar(final Calendar newCalendar)
{
  delegate.get().setCalendar(newCalendar);
}

代码示例来源:origin: EvoSuite/evosuite

public final static DateFormat getDateInstance() {
  DateFormat format = DateFormat.getDateInstance();
  format.setCalendar(MockCalendar.getInstance());
  return format;
}

代码示例来源:origin: stackoverflow.com

SimpleDateFormat format = new SimpleDateFormat("W");
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek( Calendar.MONDAY );
format.setCalendar( calendar ); 
format.format( whateverDateYouWantToFormat );`

代码示例来源:origin: stackoverflow.com

DateFormat originalDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
 DateFormat targetDateFormat = new SimpleDateFormat("EEE., MMM. dd, yyyy");
 originalDateFormat.parse(origDateString);
 targetDateFormat.setCalendar(originalDateFormat.getCalendar());
 return targetDateFormat.format(targetDateFormat.getCalendar().getTime());

相关文章