当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeFormatter.ofPattern方法代码示例

本文整理汇总了Java中java.time.format.DateTimeFormatter.ofPattern方法的典型用法代码示例。如果您正苦于以下问题:Java DateTimeFormatter.ofPattern方法的具体用法?Java DateTimeFormatter.ofPattern怎么用?Java DateTimeFormatter.ofPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.format.DateTimeFormatter的用法示例。


在下文中一共展示了DateTimeFormatter.ofPattern方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendNotificationInternal

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
private void sendNotificationInternal(String email, String sipId, String result, Instant created, String templateName) {
    try {
        DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd. MM. yyyy");

        MimeMessageHelper message = generalMessage(email, appName, false);

        Map<String, Object> params = generalArguments();
        params.put("sipId", sipId);
        params.put("result", result);
        params.put("createdDate", Utils.extractDate(created).format(dateFormatter));
        params.put("createdTime", Utils.extractTime(created).format(timeFormatter));

        InputStream template = Utils.resource(templateName);
        transformAndSend(template, params, message);
    } catch (MessagingException | IOException ex) {
        throw new GeneralException(ex);
    }
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:20,代码来源:ArclibMailCenter.java

示例2: onMessageReceived

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageReceivedEvent e) {
    String content = e.getMessage().getContent();

    //Never respond to a bot!
    if (e.getAuthor().isBot())
        return;

    //Not the `Time` command
    if (!content.equalsIgnoreCase(PREFIX + "Time")) {
        return;
    }

    receivedcmd++;

    DateTimeFormatter DTF = DateTimeFormatter.ofPattern("EE dd.MM.YYYY, HH:mm:ss | KK:mm:ss a");
    OffsetDateTime now = OffsetDateTime.now();
    e.getChannel().sendMessage("It's " + now.format(DTF)).queue();
    executedcmd++;
}
 
开发者ID:Sanduhr32,项目名称:Uselessbot,代码行数:21,代码来源:Time.java

示例3: generateProductIncrementName

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
private String generateProductIncrementName(int months){
    String pattern = "%1s-%2s";
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");

    LocalDate now = LocalDate.now();
    LocalDate changeMonthDate = now.plusMonths(months);
    String formattedChangeMonthDate = changeMonthDate.format(formatter);
    String formattedNow = now.format(formatter);

    return months < 0 ?
        String.format(pattern,formattedChangeMonthDate,formattedNow) :
        String.format(pattern,formattedNow ,formattedChangeMonthDate);
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:14,代码来源:ProgramIncrementServiceTest.java

示例4: factory_parse_formatter_nullText

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d");
    LocalDate.parse((String) null, f);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalDate.java

示例5: DateAsText

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
/**
 * Formats the milliseconds as date using the format and the locale.
 * @param milliseconds Milliseconds to format as date.
 * @param format The format to use.
 * @param locale The locale to use for the format.
 */
public DateAsText(final long milliseconds, final String format,
    final Locale locale) {
    this(
        ZonedDateTime.ofInstant(
            Instant.ofEpochMilli(milliseconds), ZoneId.of("UTC")
        ),
        DateTimeFormatter.ofPattern(format, locale)
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:16,代码来源:DateAsText.java

示例6: DefectLog

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
public DefectLog(Element e) {
	DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
	this.number = Integer.valueOf(e.getAttributeValue(NUMBER_ELEMENT));
	this.date = LocalDateTime.parse(e.getAttributeValue(DATE_ELEMENT), formatter);
	this.type = PSP.Defect.valueOf(e.getAttributeValue(TYPE_ELEMENT));
	this.injectPhase = PSP.Phase.valueOf(e.getAttributeValue(INJECT_ELEMENT));
	this.removePhase = PSP.Phase.valueOf(e.getAttributeValue(REMOVE_ELEMENT));
	this.fixMinutes = Integer.valueOf(e.getAttributeValue(FIX_ELEMENT));
	this.reference = Integer.valueOf(e.getAttributeValue(REFERENCE_ELEMENT));
	this.description = e.getAttributeValue(DESCRIPTION_ELEMENT);
	this.element = e;
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:13,代码来源:DefectLog.java

示例7: checkCustomConverter

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void checkCustomConverter() {
    final CandlestickConverter converter = new CandlestickConverter(DateTimeFormatter.ofPattern("yyyy-MM-dd"),
                                                                    DateTimeFormatter.ofPattern("HH:mm:ss"));

    final Candlestick candlestick =
            converter.convert("US33734X1928 [NA_ETF],60,2016-10-21,16:00:00,33.840000,33.960000,33.816000,33.927500,165000.000000");

    assertEquals(candlestick.getTool(), "US33734X1928 [NA_ETF]");
    assertEquals(candlestick.getCode(), "US33734X1928");
    assertEquals(candlestick.getName(), "unknown");
    assertEquals(candlestick.getDate(), LocalDate.parse("2016-10-21", converter.getDateFormatter()));
    assertEquals(candlestick.getTime(), LocalTime.parse("16:00:00", converter.getTimeFormatter()));
}
 
开发者ID:mumukiller,项目名称:stock-patterns-recognition,代码行数:15,代码来源:CandlestickConverterTest.java

示例8: transformToStr

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
public static String transformToStr(long time) {
    LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(time), ZoneId.systemDefault());
    DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(FORMATTER);
    return localDateTime.format(dateTimeFormatter);
}
 
开发者ID:DreamYa0,项目名称:zeratul,代码行数:6,代码来源:DateUtils.java

示例9: getPrettyDate

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
public static String getPrettyDate(LocalDate date) {
	DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMM", new Locale("es", "CO"));
	return date.format(formatter).toUpperCase();
}
 
开发者ID:sajhu,项目名称:nequithon,代码行数:5,代码来源:Utils.java

示例10: toString

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Override
public String toString(LocalDate date) {
	DateTimeFormatter dtFormatter = DateTimeFormatter.ofPattern(getDateFormat());
	String text = null;
	if (date != null) {
		text = dtFormatter.format(date);
	}
	return text;
}
 
开发者ID:krHasan,项目名称:Money-Manager,代码行数:10,代码来源:DateFormatManager.java

示例11: test_pattern_StringLocale

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_pattern_StringLocale() {
    DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.UK);
    assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 Jun 2012");
    assertEquals(test.getLocale(), Locale.UK);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKDateTimeFormatters.java

示例12: test_parseBest_secondOption

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void test_parseBest_secondOption() throws Exception {
    DateTimeFormatter test = DateTimeFormatter.ofPattern("yyyy-MM-dd[ HH:mm[XXX]]");
    TemporalAccessor result = test.parseBest("2011-06-30", ZonedDateTime::from, LocalDate::from);
    assertEquals(result, LocalDate.of(2011, 6, 30));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TCKDateTimeFormatter.java

示例13: factory_parse_formatter_nullText

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
    MonthDay.parse((String) null, f);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKMonthDay.java

示例14: main

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        LocalDateTime parse = LocalDateTime.parse("2012-10-01T09:45:00.000+02:00", formatter);
        //localTime();
    }
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:7,代码来源:Main.java

示例15: factory_parse_formatter

import java.time.format.DateTimeFormatter; //导入方法依赖的package包/类
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s");
    LocalTime test = LocalTime.parse("14 30 40", f);
    assertEquals(test, LocalTime.of(14, 30, 40));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TCKLocalTime.java


注:本文中的java.time.format.DateTimeFormatter.ofPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。